All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Colin Ian King <colin.king@canonical.com>,
	Peter Huewe <peterhuewe@gmx.de>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	tpmdd-devel@lists.sourceforge.net,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tpm2: fix off-by-one comparison and out-of-bounds read error
Date: Thu, 23 Mar 2017 16:42:09 +0000	[thread overview]
Message-ID: <20170323164209.GO32449@mwanda> (raw)
In-Reply-To: <20170323155358.jpotoweghjnl4vjx@intel.com>

On Thu, Mar 23, 2017 at 05:53:58PM +0200, Jarkko Sakkinen wrote:
> On Wed, Mar 22, 2017 at 04:12:49PM +0300, Dan Carpenter wrote:
> > On Wed, Mar 22, 2017 at 11:45:37AM +0000, Colin Ian King wrote:
> > > On 22/03/17 11:42, Jarkko Sakkinen wrote:
> > > > On Mon, Mar 20, 2017 at 02:23:36PM +0000, Colin King wrote:
> > > >> From: Colin Ian King <colin.king@canonical.com>
> > > >>
> > > >> The comparison of an out of range index into space->context_tbl is
> > > >> off-by-one and should be using >= rather than > in the comparison.
> > > >>
> > > >> Detected by CoverityScan, CID#1419694 ("Out-of-bounds read")
> > > >>
> > > >> Fixes: 849246e7ce9ce ("tpm2: add session handle context saving and restoring to the space code")
> > > >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > >> ---
> > > >>  drivers/char/tpm/tpm2-space.c | 2 +-
> > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >>
> > > >> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> > > >> index d36d81e07076..009934269514 100644
> > > >> --- a/drivers/char/tpm/tpm2-space.c
> > > >> +++ b/drivers/char/tpm/tpm2-space.c
> > > >> @@ -229,7 +229,7 @@ static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle)
> > > >>  	int i;
> > > >>  
> > > >>  	i = 0xFFFFFF - (vhandle & 0xFFFFFF);
> > > >> -	if (i > ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i])
> > > >> +	if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i])
> > > >>  		return false;
> > > >>  
> > > >>  	phandle = space->context_tbl[i];
> > > >> -- 
> > > >> 2.11.0
> > > > 
> > > > Thanks. If you don't mind, I would squash this to that patch?
> > > > 
> > > > /Jarkko
> > > > 
> > > Sure squash it, and maybe add a Reported-by: Colin Ian King
> > > <colin.king@canonical.com> if that's OK with you.
> > 
> > Reported-by isn't really correct though...  We should have a Fixes-from:
> > tag for squashed fixes.
> > 
> > regards,
> > dan carpenter
> 
> Hmm... Maybe so depending on how you interpret Reported-by but
> Fixes-from is not something that is used at the moment, is it?

No, but we should create it.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Colin Ian King <colin.king@canonical.com>,
	Peter Huewe <peterhuewe@gmx.de>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	tpmdd-devel@lists.sourceforge.net,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tpm2: fix off-by-one comparison and out-of-bounds read error
Date: Thu, 23 Mar 2017 19:42:09 +0300	[thread overview]
Message-ID: <20170323164209.GO32449@mwanda> (raw)
In-Reply-To: <20170323155358.jpotoweghjnl4vjx@intel.com>

On Thu, Mar 23, 2017 at 05:53:58PM +0200, Jarkko Sakkinen wrote:
> On Wed, Mar 22, 2017 at 04:12:49PM +0300, Dan Carpenter wrote:
> > On Wed, Mar 22, 2017 at 11:45:37AM +0000, Colin Ian King wrote:
> > > On 22/03/17 11:42, Jarkko Sakkinen wrote:
> > > > On Mon, Mar 20, 2017 at 02:23:36PM +0000, Colin King wrote:
> > > >> From: Colin Ian King <colin.king@canonical.com>
> > > >>
> > > >> The comparison of an out of range index into space->context_tbl is
> > > >> off-by-one and should be using >= rather than > in the comparison.
> > > >>
> > > >> Detected by CoverityScan, CID#1419694 ("Out-of-bounds read")
> > > >>
> > > >> Fixes: 849246e7ce9ce ("tpm2: add session handle context saving and restoring to the space code")
> > > >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > >> ---
> > > >>  drivers/char/tpm/tpm2-space.c | 2 +-
> > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >>
> > > >> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> > > >> index d36d81e07076..009934269514 100644
> > > >> --- a/drivers/char/tpm/tpm2-space.c
> > > >> +++ b/drivers/char/tpm/tpm2-space.c
> > > >> @@ -229,7 +229,7 @@ static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle)
> > > >>  	int i;
> > > >>  
> > > >>  	i = 0xFFFFFF - (vhandle & 0xFFFFFF);
> > > >> -	if (i > ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i])
> > > >> +	if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i])
> > > >>  		return false;
> > > >>  
> > > >>  	phandle = space->context_tbl[i];
> > > >> -- 
> > > >> 2.11.0
> > > > 
> > > > Thanks. If you don't mind, I would squash this to that patch?
> > > > 
> > > > /Jarkko
> > > > 
> > > Sure squash it, and maybe add a Reported-by: Colin Ian King
> > > <colin.king@canonical.com> if that's OK with you.
> > 
> > Reported-by isn't really correct though...  We should have a Fixes-from:
> > tag for squashed fixes.
> > 
> > regards,
> > dan carpenter
> 
> Hmm... Maybe so depending on how you interpret Reported-by but
> Fixes-from is not something that is used at the moment, is it?

No, but we should create it.

regards,
dan carpenter

  parent reply	other threads:[~2017-03-23 16:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 14:23 [PATCH] tpm2: fix off-by-one comparison and out-of-bounds read error Colin King
2017-03-20 14:23 ` Colin King
2017-03-22 11:42 ` Jarkko Sakkinen
2017-03-22 11:42   ` Jarkko Sakkinen
2017-03-22 11:42   ` Jarkko Sakkinen
2017-03-22 11:45   ` Colin Ian King
2017-03-22 13:12     ` Dan Carpenter
2017-03-22 13:12       ` Dan Carpenter
2017-03-23 15:53       ` Jarkko Sakkinen
2017-03-23 15:53         ` Jarkko Sakkinen
2017-03-23 16:23         ` Jarkko Sakkinen
2017-03-23 16:23           ` Jarkko Sakkinen
2017-03-23 16:23           ` Jarkko Sakkinen
2017-03-23 16:42         ` Dan Carpenter [this message]
2017-03-23 16:42           ` Dan Carpenter
2017-03-23 18:12           ` Jarkko Sakkinen
2017-03-23 18:12             ` Jarkko Sakkinen
2017-03-23 18:12             ` Jarkko Sakkinen
2017-03-23 15:51     ` Jarkko Sakkinen
2017-03-23 15:51       ` Jarkko Sakkinen
2017-03-23 15:51       ` Jarkko Sakkinen

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=20170323164209.GO32449@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=colin.king@canonical.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.