From: "jarkko@kernel.org" <jarkko@kernel.org>
To: Haitao Huang <haitao.huang@linux.intel.com>
Cc: "Huang, Kai" <kai.huang@intel.com>,
"pmenzel@molgen.mpg.de" <pmenzel@molgen.mpg.de>,
"linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"Dhanraj, Vijay" <vijay.dhanraj@intel.com>,
"Chatre, Reinette" <reinette.chatre@intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"bp@alien8.de" <bp@alien8.de>, "hpa@zytor.com" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/6] x86/sgx: Do not consider unsanitized pages an error
Date: Wed, 31 Aug 2022 21:28:23 +0300 [thread overview]
Message-ID: <Yw+oR3FKlwbeOl6I@kernel.org> (raw)
In-Reply-To: <op.1rrt4aecwjvjmi@hhuan26-mobl1.mshome.net>
On Wed, Aug 31, 2022 at 10:18:00AM -0500, Haitao Huang wrote:
> Hi Kai
> On Tue, 30 Aug 2022 22:17:08 -0500, Huang, Kai <kai.huang@intel.com> wrote:
>
> > On Wed, 2022-08-31 at 05:57 +0300, jarkko@kernel.org wrote:
> > > On Wed, Aug 31, 2022 at 02:55:52AM +0000, Huang, Kai wrote:
> > > > On Wed, 2022-08-31 at 05:44 +0300, jarkko@kernel.org wrote:
> > > > > On Wed, Aug 31, 2022 at 02:35:53AM +0000, Huang, Kai wrote:
> > > > > > On Wed, 2022-08-31 at 05:15 +0300, jarkko@kernel.org wrote:
> > > > > > > On Wed, Aug 31, 2022 at 01:27:58AM +0000, Huang, Kai wrote:
> > > > > > > > On Tue, 2022-08-30 at 15:54 -0700, Reinette Chatre wrote:
> > > > > > > > > Hi Jarkko,
> > > > > > > > >
> > > > > > > > > On 8/29/2022 8:12 PM, Jarkko Sakkinen wrote:
> > > > > > > > > > In sgx_init(), if misc_register() for the provision
> > > device fails, and
> > > > > > > > > > neither sgx_drv_init() nor sgx_vepc_init() succeeds,
> > > then ksgxd will be
> > > > > > > > > > prematurely stopped.
> > > > > > > > >
> > > > > > > > > I do not think misc_register() is required to fail for
> > > the scenario to
> > > > > > > > > be triggered (rather use "or" than "and"?). Perhaps just
> > > > > > > > > "In sgx_init(), if a failure is encountered after ksgxd
> > > is started
> > > > > > > > > (via sgx_page_reclaimer_init()) ...".
> > > > > > > >
> > > > > > > > IMHO "a failure" might be too vague. For instance,
> > > failure to sgx_drv_init()
> > > > > > > > won't immediately result in ksgxd to stop prematurally.
> > > As long as KVM SGX can
> > > > > > > > be initialized successfully, sgx_init() still returns 0.
> > > > > > > >
> > > > > > > > Btw I was thinking whether we should move
> > > sgx_page_reclaimer_init() to the end
> > > > > > > > of sgx_init(), after we make sure at least one of the
> > > driver and the KVM SGX is
> > > > > > > > initialized successfully. Then the code change in this
> > > patch won't be necessary
> > > > > > > > if I understand correctly. AFAICT there's no good reason
> > > to start the ksgxd at
> > > > > > > > early stage before we are sure either the driver or KVM
> > > SGX will work.
> > > > > > >
> > > > > > > I would focus fixing the existing flow rather than
> > > reinventing the flow.
> > > > > > >
> > > > > > > It can be made to work, and therefore it is IMHO correct
> > > action to take.
> > > > > >
> > > > > > From another perspective, the *existing flow* is the reason
> > > which causes this
> > > > > > bug. A real fix is to fix the flow itself.
> > > > >
> > > > > Any existing flow in part of the kernel can have a bug. That
> > > > > does not mean that switching flow would be proper way to fix
> > > > > a bug.
> > > > >
> > > > > BR, Jarkko
> > > >
> > > > Yes but I think this is only true when the flow is reasonable. If
> > > the flow
> > > > itself isn't reasonable, we should fix the flow (given it's easy
> > > to fix AFAICT).
> > > >
> > > > Anyway, let us also hear from others.
> > >
> > > The flow can be made to work without issues, which in the
> > > context of a bug fix is exactly what a bug fix should do.
> > > Not more or less.
> >
> > No. To me the flow itself is buggy. There's no reason to start ksgxd()
> > before
> > at least SGX driver is initialized to work.
> >
>
> Will it cause racing if we expose dev nodes to user space before
> ksgxd is started and sensitization done?
I'll to explain this.
So the point is to fix the issue at hand, and fix it locally.
Changing initialization order is simply out of context. It's
not really an argument for or against changing it
We are fixing sanitization here, and only that with zero
side-effects to any other semantics.
It's dictated by the development process [*] but more
importantly it's also just plain common sense.
[*] https://www.kernel.org/doc/html/v5.19/process/submitting-patches.html#separate-your-changes
BR, Jarkko
next prev parent reply other threads:[~2022-08-31 18:34 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 3:12 [PATCH 0/6] x86/sgx: Test and fixes Jarkko Sakkinen
2022-08-30 3:12 ` [PATCH 1/6] x86/sgx: Do not consider unsanitized pages an error Jarkko Sakkinen
2022-08-30 22:54 ` Reinette Chatre
2022-08-31 1:27 ` Huang, Kai
2022-08-31 2:15 ` jarkko
2022-08-31 2:35 ` Huang, Kai
2022-08-31 2:44 ` jarkko
2022-08-31 2:55 ` Huang, Kai
2022-08-31 2:57 ` jarkko
2022-08-31 3:10 ` Jarkko Sakkinen
2022-08-31 3:28 ` Huang, Kai
2022-08-31 3:40 ` jarkko
2022-08-31 3:17 ` Huang, Kai
2022-08-31 15:18 ` Haitao Huang
2022-08-31 18:28 ` jarkko [this message]
2022-08-31 18:35 ` Dave Hansen
2022-08-31 18:44 ` jarkko
2022-08-31 18:45 ` jarkko
2022-08-31 20:42 ` Huang, Kai
2022-09-01 22:27 ` jarkko
2022-09-01 22:41 ` Huang, Kai
2022-09-01 23:58 ` jarkko
2022-09-02 0:26 ` Huang, Kai
2022-08-31 1:55 ` Jarkko Sakkinen
2022-08-31 1:58 ` Jarkko Sakkinen
2022-08-31 2:01 ` Jarkko Sakkinen
2022-08-31 18:08 ` Reinette Chatre
2022-08-30 3:12 ` [PATCH 2/6] x86/sgx: Handle VA page allocation failure for EAUG on PF Jarkko Sakkinen
2022-08-30 22:54 ` Reinette Chatre
2022-08-30 3:12 ` [PATCH 3/6] selftests/sgx: Ignore OpenSSL 3.0 deprecated functions warning Jarkko Sakkinen
2022-08-30 18:18 ` Reinette Chatre
2022-08-31 1:07 ` Jarkko Sakkinen
2022-08-30 3:12 ` [PATCH 4/6] selftests/sgx: Add SGX selftest augment_via_eaccept_long Jarkko Sakkinen
2022-08-30 22:55 ` Reinette Chatre
2022-08-31 2:28 ` Jarkko Sakkinen
2022-08-31 18:09 ` Reinette Chatre
2022-09-01 22:16 ` Jarkko Sakkinen
2022-09-01 23:11 ` Reinette Chatre
2022-09-02 0:00 ` Jarkko Sakkinen
2022-09-02 0:02 ` Jarkko Sakkinen
2022-08-30 3:12 ` [PATCH 5/6] selftests/sgx: retry the ioctls returned with EAGAIN Jarkko Sakkinen
2022-08-30 22:56 ` Reinette Chatre
2022-08-31 2:31 ` Jarkko Sakkinen
2022-08-31 18:09 ` Reinette Chatre
2022-09-01 22:17 ` Jarkko Sakkinen
2022-08-31 18:14 ` Dave Hansen
2022-09-01 22:18 ` Jarkko Sakkinen
2022-08-30 3:12 ` [PATCH 6/6] selftests/sgx: Add a bpftrace script for tracking allocation errors Jarkko Sakkinen
2022-08-30 22:57 ` Reinette Chatre
2022-08-31 2:33 ` Jarkko Sakkinen
2022-08-31 18:10 ` Reinette Chatre
2022-08-31 18:23 ` Jarkko Sakkinen
2022-08-31 18:23 ` Dave Hansen
2022-09-01 22:20 ` Jarkko Sakkinen
2022-09-01 22:34 ` Dave Hansen
2022-09-01 23:55 ` 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=Yw+oR3FKlwbeOl6I@kernel.org \
--to=jarkko@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=haitao.huang@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pmenzel@molgen.mpg.de \
--cc=reinette.chatre@intel.com \
--cc=tglx@linutronix.de \
--cc=vijay.dhanraj@intel.com \
--cc=x86@kernel.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