Re: [PATCH 5/8] ima: allocate and initialize tfm for each PCR bank
From: Mimi Zohar
Date: Fri Jan 31 2020 - 08:58:39 EST
On Fri, 2020-01-31 at 13:42 +0000, Roberto Sassu wrote:
> > -----Original Message-----
> > From: linux-integrity-owner@xxxxxxxxxxxxxxx [mailto:linux-integrity-
> > owner@xxxxxxxxxxxxxxx] On Behalf Of Mimi Zohar
> > Sent: Friday, January 31, 2020 1:19 PM
> > To: Roberto Sassu <roberto.sassu@xxxxxxxxxx>;
> > jarkko.sakkinen@xxxxxxxxxxxxxxx;
> > james.bottomley@xxxxxxxxxxxxxxxxxxxxx; linux-integrity@xxxxxxxxxxxxxxx
> > Cc: linux-security-module@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> > Silviu Vlasceanu <Silviu.Vlasceanu@xxxxxxxxxx>
> > Subject: Re: [PATCH 5/8] ima: allocate and initialize tfm for each PCR bank
> >
> > On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote:
> > > This patch creates a crypto_shash structure for each allocated PCR bank
> > and
> > > for SHA1 if a bank with that algorithm is not currently allocated.
> > >
> > > Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
> >
> > <snip>
> >
> > > +int __init ima_init_crypto(void)
> > > +{
> > > + enum hash_algo algo;
> > > + long rc;
> > > + int i;
> > > +
> > > + rc = ima_init_ima_crypto();
> > > + if (rc)
> > > + return rc;
> > > +
> > > + ima_algo_array = kmalloc_array(ima_tpm_chip-
> > >nr_allocated_banks + 1,
> > > + sizeof(*ima_algo_array), GFP_KERNEL);
> >
> > Perhaps instead of hard coding "nr_allocated_banks + 1", create a
> > variable for storing the number of "extra" banks. ÂWalk the banks
> > setting ima_sha1_idx and, later, in a subsequent patch set
> > ima_hash_algo_idx.
>
> I could store the indexes in an array and add ARRAY_SIZE of that array.
Your current patches are straight forward and easy to review.ÂÂI
really like that. ÂWhat I'm proposing is a minor change, at least I
think it is a minor change. ÂI trust whatever change you decide to
make will be just as easy to review.
Before re-posting, please define ima_sha1_idx and ima_hash_algo_idx as
__ro_after_init.
thanks,
Mimi