2020-01-27 17:07:42

by Roberto Sassu

[permalink] [raw]
Subject: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

chip->allocated_banks contains the list of TPM algorithm IDs of allocated
PCR banks. It also contains the corresponding ID of the crypto subsystem,
so that users of the TPM driver can calculate a digest for a PCR extend
operation.

However, if there is no mapping between TPM algorithm ID and crypto ID, the
crypto_id field in chip->allocated_banks remains set to zero (the array is
allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
Zero should not be used as value for unknown mappings, as it is a valid
crypto ID (HASH_ALGO_MD4).

This patch initializes crypto_id to HASH_ALGO__LAST.

Signed-off-by: Roberto Sassu <[email protected]>
---
drivers/char/tpm/tpm2-cmd.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 13696deceae8..760329598b99 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -525,6 +525,8 @@ static int tpm2_init_bank_info(struct tpm_chip *chip, u32 bank_index)
return 0;
}

+ bank->crypto_id = HASH_ALGO__LAST;
+
return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size);
}

--
2.17.1


2020-01-29 08:40:15

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

Hi Roberto,

> chip->allocated_banks contains the list of TPM algorithm IDs of allocated
> PCR banks. It also contains the corresponding ID of the crypto subsystem,
> so that users of the TPM driver can calculate a digest for a PCR extend
> operation.

> However, if there is no mapping between TPM algorithm ID and crypto ID, the
> crypto_id field in chip->allocated_banks remains set to zero (the array is
> allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
> Zero should not be used as value for unknown mappings, as it is a valid
> crypto ID (HASH_ALGO_MD4).

> This patch initializes crypto_id to HASH_ALGO__LAST.

Make sense.
Reviewed-by: Petr Vorel <[email protected]>

Kind regards,
Petr

2020-01-30 08:48:56

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote:
> chip->allocated_banks contains the list of TPM algorithm IDs of allocated
> PCR banks. It also contains the corresponding ID of the crypto subsystem,
> so that users of the TPM driver can calculate a digest for a PCR extend
> operation.
>
> However, if there is no mapping between TPM algorithm ID and crypto ID, the
> crypto_id field in chip->allocated_banks remains set to zero (the array is
> allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
> Zero should not be used as value for unknown mappings, as it is a valid
> crypto ID (HASH_ALGO_MD4).
>
> This patch initializes crypto_id to HASH_ALGO__LAST.
>
> Signed-off-by: Roberto Sassu <[email protected]>---

Remarks:

* After the subsystem tag, short summary starts with a capital lettter.
* Missing fixes tag and cc tag to stable.
* A struct called allocated_banks does not exist.
* Please prefer using an imperative sentence when describing the action
to take e.g. "Thus, initialize crypto_id to HASH_ALGO__LAST".

/Jarkko

2020-01-30 16:12:34

by Roberto Sassu

[permalink] [raw]
Subject: RE: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

> -----Original Message-----
> From: Jarkko Sakkinen [mailto:[email protected]]
> Sent: Thursday, January 30, 2020 9:48 AM
> To: Roberto Sassu <[email protected]>; [email protected];
> [email protected]; [email protected]
> Cc: [email protected]; [email protected];
> Silviu Vlasceanu <[email protected]>
> Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to
> HASH_ALGO__LAST
>
> On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote:
> > chip->allocated_banks contains the list of TPM algorithm IDs of allocated
> > PCR banks. It also contains the corresponding ID of the crypto subsystem,
> > so that users of the TPM driver can calculate a digest for a PCR extend
> > operation.
> >
> > However, if there is no mapping between TPM algorithm ID and crypto ID,
> the
> > crypto_id field in chip->allocated_banks remains set to zero (the array is
> > allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
> > Zero should not be used as value for unknown mappings, as it is a valid
> > crypto ID (HASH_ALGO_MD4).
> >
> > This patch initializes crypto_id to HASH_ALGO__LAST.
> >
> > Signed-off-by: Roberto Sassu <[email protected]>---
>
> Remarks:
>
> * After the subsystem tag, short summary starts with a capital lettter.
> * Missing fixes tag and cc tag to stable.
> * A struct called allocated_banks does not exist.
> * Please prefer using an imperative sentence when describing the action
> to take e.g. "Thus, initialize crypto_id to HASH_ALGO__LAST".

Thanks. I will fix these issues in the next version of the patch set.

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli

2020-01-31 13:34:33

by Mimi Zohar

[permalink] [raw]
Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

On Thu, 2020-01-30 at 16:11 +0000, Roberto Sassu wrote:
> > -----Original Message-----
> > From: Jarkko Sakkinen [mailto:[email protected]]
> > Sent: Thursday, January 30, 2020 9:48 AM
> > To: Roberto Sassu <[email protected]>; [email protected];
> > [email protected]; [email protected]
> > Cc: [email protected]; [email protected];
> > Silviu Vlasceanu <[email protected]>
> > Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to
> > HASH_ALGO__LAST
> >
> > On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote:
> > > chip->allocated_banks contains the list of TPM algorithm IDs of allocated
> > > PCR banks. It also contains the corresponding ID of the crypto subsystem,
> > > so that users of the TPM driver can calculate a digest for a PCR extend
> > > operation.
> > >
> > > However, if there is no mapping between TPM algorithm ID and crypto ID,
> > the
> > > crypto_id field in chip->allocated_banks remains set to zero (the array is
> > > allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
> > > Zero should not be used as value for unknown mappings, as it is a valid
> > > crypto ID (HASH_ALGO_MD4).
> > >
> > > This patch initializes crypto_id to HASH_ALGO__LAST.
> > >
> > > Signed-off-by: Roberto Sassu <[email protected]>---
> >
> > Remarks:
> >
> > * After the subsystem tag, short summary starts with a capital lettter.
> > * Missing fixes tag and cc tag to stable.
> > * A struct called allocated_banks does not exist.
> > * Please prefer using an imperative sentence when describing the action
> > to take e.g. "Thus, initialize crypto_id to HASH_ALGO__LAST".
>
> Thanks. I will fix these issues in the next version of the patch set.

Jarkko, I realize this is a TPM patch, but this patch set is dependent
on it.  When this patch is ready, could you create a topic branch,
which both of us could merge?

thanks,

Mimi

2020-02-01 17:13:03

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST

On Fri, Jan 31, 2020 at 08:33:10AM -0500, Mimi Zohar wrote:
> On Thu, 2020-01-30 at 16:11 +0000, Roberto Sassu wrote:
> > > -----Original Message-----
> > > From: Jarkko Sakkinen [mailto:[email protected]]
> > > Sent: Thursday, January 30, 2020 9:48 AM
> > > To: Roberto Sassu <[email protected]>; [email protected];
> > > [email protected]; [email protected]
> > > Cc: [email protected]; [email protected];
> > > Silviu Vlasceanu <[email protected]>
> > > Subject: Re: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to
> > > HASH_ALGO__LAST
> > >
> > > On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote:
> > > > chip->allocated_banks contains the list of TPM algorithm IDs of allocated
> > > > PCR banks. It also contains the corresponding ID of the crypto subsystem,
> > > > so that users of the TPM driver can calculate a digest for a PCR extend
> > > > operation.
> > > >
> > > > However, if there is no mapping between TPM algorithm ID and crypto ID,
> > > the
> > > > crypto_id field in chip->allocated_banks remains set to zero (the array is
> > > > allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()).
> > > > Zero should not be used as value for unknown mappings, as it is a valid
> > > > crypto ID (HASH_ALGO_MD4).
> > > >
> > > > This patch initializes crypto_id to HASH_ALGO__LAST.
> > > >
> > > > Signed-off-by: Roberto Sassu <[email protected]>---
> > >
> > > Remarks:
> > >
> > > * After the subsystem tag, short summary starts with a capital lettter.
> > > * Missing fixes tag and cc tag to stable.
> > > * A struct called allocated_banks does not exist.
> > > * Please prefer using an imperative sentence when describing the action
> > > to take e.g. "Thus, initialize crypto_id to HASH_ALGO__LAST".
> >
> > Thanks. I will fix these issues in the next version of the patch set.
>
> Jarkko, I realize this is a TPM patch, but this patch set is dependent
> on it. ?When this patch is ready, could you create a topic branch,
> which both of us could merge?

WFM.

/Jarkko