[PATCH v6 1/7] tpm: dynamically allocate the allocated_banks array

Roberto Sassu roberto.sassu at huawei.com
Thu Dec 13 08:14:23 UTC 2018


On 12/12/2018 7:32 PM, Jarkko Sakkinen wrote:
> On Thu, Dec 06, 2018 at 06:56:33PM +0100, Roberto Sassu wrote:
>> 2 PCR selections
>>      hash TPM_ALG_SHA1
>>      TPMS_PCR_SELECTION length 3
>>      ff ff ff
>>      hash TPM_ALG_SHA256
>>      TPMS_PCR_SELECTION length 3
>>      00 00 00
>>
>> The pcr_select fields - "ff ff ff" and "00 00 00" - are bit masks for
>> the enabled PCRs. The SHA1 bank is enabled for all PCRs (0-23), while
>> the SHA256 bank is not enabled.
> 
> Uh, thanks. Can you add a note to the commit message?

Ok.


>>>
>>> /* Check that at least some of the PCRs have been allocated. This is
>>>    * required because CAP_PCRS ...
>>>    */
>>> if (memchr_inv(pcr_selection.pcr_select, 0, pcr_selection.size_of_select))
>>> 	nr_allocated_banks++;
>>>
>>> [yeah, comment would be awesome about CAP_PCRS. Did not finish up the
>>> comment because I don't know the answer]
>>>
>>> In addition, it would be consistent to call the local variable also
>>> nr_allocated_banks (not nr_alloc_banks).
>>
>> Unfortunately, I exceed the limit of characters per line.
> 
> Not sure what you mean?

---
-		chip->allocated_banks[nr_alloc_banks] = hash_alg;
+		chip->allocated_banks[nr_alloc_banks].alg_id = hash_alg;
---

If I use nr_allocated_banks, the line above (see patch 5/7) exceeds the
limit of 80 characters.

Roberto


> /Jarkko
> 

-- 
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Bo PENG, Jian LI, Yanli SHI



More information about the Linux-security-module-archive mailing list