All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-sgx@vger.kernel.org,
	Reinette Chatre <reinette.chatre@intel.com>,
	Borislav Petkov <bp@alien8.de>,
	Tianjia Zhang <tianjia.zhang@linux.alibaba.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Jethro Beekman <jethro@fortanix.com>,
	Borislav Petkov <bp@suse.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] selftests/sgx: Fix Q1 and Q2 calculation in sigstruct.c
Date: Wed, 7 Jul 2021 02:52:17 +0300	[thread overview]
Message-ID: <20210706235217.6mre4arpgfsrdxm4@kernel.org> (raw)
In-Reply-To: <4303b822-5861-ba2c-f620-0e752e499329@intel.com>

On Tue, Jul 06, 2021 at 01:53:20PM -0700, Dave Hansen wrote:
> On 7/5/21 7:36 AM, Jarkko Sakkinen wrote:
> > From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> > 
> > Q1 and Q2 are numbers with *maximum* length of 384 bytes. If the calculated
> > length of Q1 and Q2 is less than 384 bytes, things will go wrong.
> > 
> > E.g. if Q2 is 383 bytes, then
> > 
> > 1. The bytes of q2 are copied to sigstruct->q2 in calc_q1q2().
> > 2. The entire sigstruct->q2 is reversed, which results it being
> >    256 * Q2, given that the last byte of sigstruct->q2 is added
> >    to before the bytes given by calc_q1q2().
> > 
> > Either change in key or measurement can trigger the bug. E.g. an unmeasured
> > heap could cause a devastating change in Q1 or Q2.
> > 
> > Reverse exactly the bytes of Q1 and Q2 in calc_q1q2() before returning to
> > the caller.
> > 
> > Fixes: 2adcba79e69d ("selftests/x86: Add a selftest for SGX")
> > Link: https://lore.kernel.org/linux-sgx/20210301051836.30738-1-tianjia.zhang@linux.alibaba.com/
> > Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> 
> This looks fine, but can I suggest a Subject: tweak?
> 
> 	selftests/sgx: Fix calculations for sub-maximum field sizes

WFM

> 
> In any case:
> 
> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>

Thank you.

/Jarkko

  reply	other threads:[~2021-07-06 23:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 14:36 [PATCH 0/4] selftests/sgx: Trigger the page reclaimer and #PF handler Jarkko Sakkinen
2021-07-05 14:36 ` [PATCH 1/4] x86/sgx: Add sgx_nr_all_pages to the debugfs Jarkko Sakkinen
2021-07-06 14:56   ` Dave Hansen
2021-07-06 15:39     ` Greg KH
2021-07-06 22:08     ` Jarkko Sakkinen
2021-07-05 14:36 ` [PATCH 2/4] selftests/sgx: Fix Q1 and Q2 calculation in sigstruct.c Jarkko Sakkinen
2021-07-06 20:53   ` Dave Hansen
2021-07-06 23:52     ` Jarkko Sakkinen [this message]
2021-07-05 14:36 ` [PATCH 3/4] selftests/sgx: Assign source for each segment Jarkko Sakkinen
2021-07-05 14:36 ` [PATCH 4/4] selftests/sgx: Trigger the reclaimer and #PF handler Jarkko Sakkinen
2021-07-06 18:34   ` Reinette Chatre
2021-07-06 23:50     ` Jarkko Sakkinen
2021-07-07  0:10       ` Reinette Chatre
2021-07-07  9:17         ` Jarkko Sakkinen
2021-07-07 15:02           ` Reinette Chatre
2021-07-07 20:50             ` Jarkko Sakkinen
2021-07-07 21:20               ` Reinette Chatre
2021-07-09 16:22                 ` Jarkko Sakkinen
2021-07-07 21:20               ` Dave Hansen
2021-07-09 16:25                 ` 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=20210706235217.6mre4arpgfsrdxm4@kernel.org \
    --to=jarkko@kernel.org \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jethro@fortanix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    --cc=tianjia.zhang@linux.alibaba.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 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.