linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huawei.com>
To: Mimi Zohar <zohar@linux.ibm.com>, <jarkko.sakkinen@linux.intel.com>
Cc: <linux-integrity@vger.kernel.org>,
	<linux-security-module@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <silviu.vlasceanu@huawei.com>
Subject: Re: [PATCH v3 1/5] tpm: change the end marker of the active_banks array to zero
Date: Mon, 5 Nov 2018 09:10:58 +0100	[thread overview]
Message-ID: <b2622675-041b-c1af-4670-aecab2adf3ac@huawei.com> (raw)
In-Reply-To: <1541083377.4035.13.camel@linux.ibm.com>

On 11/1/2018 3:42 PM, Mimi Zohar wrote:
> On Wed, 2018-10-31 at 10:43 -0400, Mimi Zohar wrote:
>> On Tue, 2018-10-30 at 16:47 +0100, Roberto Sassu wrote:
>>> This patch changes the end marker of the active_banks array from
>>> TPM2_ALG_ERROR to zero.
>>
>> The patch description is a bit off.
>>
>> TPM2_ALG_ERROR is defined as zero.  Since tpm_chip_alloc() calls
>> kzalloc to allocate the structure, there is no need to explicitly set
>> the active_banks end marker to TPM2_ALG_ERROR, nor is there a need to
>> explicitly test for the end marker.
>>
>> This patch removes explicitly setting the end marker and changes the
>> coding style.
>>
>>>
>>> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
>>> ---
>>>   drivers/char/tpm/tpm-interface.c | 2 +-
>>>   drivers/char/tpm/tpm2-cmd.c      | 3 ---
>>>   2 files changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
>>> index 1a803b0cf980..f7fc4b5ee239 100644
>>> --- a/drivers/char/tpm/tpm-interface.c
>>> +++ b/drivers/char/tpm/tpm-interface.c
>>> @@ -1051,7 +1051,7 @@ int tpm_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash)
>>>   		memset(digest_list, 0, sizeof(digest_list));
>>>   
>>>   		for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
>>> -			    chip->active_banks[i] != TPM2_ALG_ERROR; i++) {
>>> +			    chip->active_banks[i]; i++) {
>>>   			digest_list[i].alg_id = chip->active_banks[i];
>>>   			memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
>>>   			count++;
> 
> The fourth patch further updates this code.  Please move those changes
> to this first patch.  No need to touch the same code in both places.

alg_id is introduced in patch 4/5. It cannot be moved here.

Roberto


>                  for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
> -                           chip->active_banks[i]; i++) {
> -                       digest_list[i].alg_id = chip->active_banks[i];
> +                           chip->active_banks[i].alg_id; i++) {
> +                       digest_list[i].alg_id = chip->active_banks[i].alg_id;
>                          memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
>                          count++;
>                  }
> Mimi
> 
>>> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
>>> index c31b490bd41d..046c9d8f3c1e 100644
>>> --- a/drivers/char/tpm/tpm2-cmd.c
>>> +++ b/drivers/char/tpm/tpm2-cmd.c
>>> @@ -908,9 +908,6 @@ static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
>>>   	}
>>>   
>>>   out:
>>> -	if (i < ARRAY_SIZE(chip->active_banks))
>>> -		chip->active_banks[i] = TPM2_ALG_ERROR;
>>> -
>>>   	tpm_buf_destroy(&buf);
>>>   
>>>   	return rc;
>>
> 

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

  reply	other threads:[~2018-11-05  8:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 15:47 [PATCH v3 0/5] tpm: retrieve digest size of unknown algorithms from TPM Roberto Sassu
2018-10-30 15:47 ` [PATCH v3 1/5] tpm: change the end marker of the active_banks array to zero Roberto Sassu
2018-10-30 19:45   ` Jarkko Sakkinen
2018-10-31 14:43   ` Mimi Zohar
2018-11-01 14:42     ` Mimi Zohar
2018-11-05  8:10       ` Roberto Sassu [this message]
2018-11-05 13:02         ` Mimi Zohar
2018-11-05  8:07     ` Roberto Sassu
2018-10-30 15:47 ` [PATCH v3 2/5] tpm: rename and export tpm2_digest and tpm2_algorithms Roberto Sassu
2018-10-30 15:47 ` [PATCH v3 3/5] tpm: modify tpm_pcr_read() definition to pass a TPM hash algorithm Roberto Sassu
2018-10-30 15:47 ` [PATCH v3 4/5] tpm: retrieve digest size of unknown algorithms with PCR read Roberto Sassu
2018-11-01 16:02   ` Mimi Zohar
2018-11-01 16:23     ` Mimi Zohar
2018-11-05  9:47     ` Roberto Sassu
2018-11-05 12:01       ` Jarkko Sakkinen
2018-11-05 13:09         ` Roberto Sassu
2018-11-05 14:48           ` Mimi Zohar
2018-11-05 17:13           ` Jarkko Sakkinen
2018-11-05 17:10         ` Jarkko Sakkinen
2018-10-30 15:47 ` [PATCH v3 5/5] tpm: ensure that output of PCR read contains the correct digest size Roberto Sassu
2018-10-30 19:52   ` Jarkko Sakkinen
2018-10-31  8:16     ` Roberto Sassu
2018-11-01 14:32       ` Jarkko Sakkinen
2018-11-01 16:52   ` Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2622675-041b-c1af-4670-aecab2adf3ac@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=silviu.vlasceanu@huawei.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).