qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Liam Merwick <liam.merwick@oracle.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] tpm_tis: validate locality values don't overrun array
Date: Fri, 8 Feb 2019 16:29:16 -0500	[thread overview]
Message-ID: <00ecb179-65e9-2bb3-5199-b7d26af7069c@linux.ibm.com> (raw)
In-Reply-To: <cf016219-65e7-a768-91a8-9a674a1ddba4@linux.ibm.com>

On 2/8/19 3:38 PM, Stefan Berger wrote:
> On 2/8/19 3:10 PM, Liam Merwick wrote:
>>
>>
>>
>> From staring at the code, I do have one other question - why does the 
>> check of the lower localities below only check 'l < locty - 1' before 
>> setting s->loc[locty] - it seems like s->loc[locty - 1] is skipped.
>>
>>
>>  627                 /* cancel any seize by a lower locality */
>>  628                 for (l = 0; l < locty - 1; l++) {
>>  629                     s->loc[l].access &= ~TPM_TIS_ACCESS_SEIZE;
>>  630                 }
>
>
> Uuuh. The loop is clearing the SEIZE flag on localities lower than the 
> current one. This works fine for locty >= 1, but not for locty = 0. I 
> think there's a bug here.


Actually, the compiler is smarter than that. With locty = 0, and l = 0,  
l < locty - 1 evaluates to 'false' and the loop doesn't get executed! 
Lucky me.

    Stefan


      reply	other threads:[~2019-02-08 21:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 14:45 [Qemu-devel] [PATCH] tpm_tis: validate locality values don't overrun array Liam Merwick
2019-02-04 18:05 ` Stefan Berger
2019-02-08 20:10   ` Liam Merwick
2019-02-08 20:38     ` Stefan Berger
2019-02-08 21:29       ` Stefan Berger [this message]

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=00ecb179-65e9-2bb3-5199-b7d26af7069c@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=liam.merwick@oracle.com \
    --cc=qemu-devel@nongnu.org \
    /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).