From: Jarkko Sakkinen <jarkko@kernel.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Sean Christopherson <seanjc@google.com>,
linux-sgx@vger.kernel.org, kai.huang@intel.com,
haitao.huang@intel.com, stable@vger.kernel.org,
Haitao Huang <haitao.huang@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Jethro Beekman <jethro@fortanix.com>
Subject: Re: [PATCH v4] x86/sgx: Fix the call order of synchronize_srcu() in sgx_release()
Date: Wed, 27 Jan 2021 19:31:55 +0200 [thread overview]
Message-ID: <YBGji9ZAS23r35Vo@kernel.org> (raw)
In-Reply-To: <5b881022-d9f1-3ac4-89e5-7da6d6ce2fc8@intel.com>
On Mon, Jan 25, 2021 at 07:49:04AM -0800, Dave Hansen wrote:
> Haitao managed to create another splat over the weekend. It was, indeed:
>
> > WARNING: CPU: 3 PID: 7620 at kernel/rcu/srcutree.c:374 cleanup_srcu_struct+0xed/0x100
>
> which is:
>
> > if (WARN_ON(!srcu_get_delay(ssp)))
> > return; /* Just leak it! */
>
> That check means that there is an outstanding "expedited" grace period.
> The fact that it's expedited is not important. This:
>
> https://lwn.net/Articles/202847/
>
> describes the reasoning behind the warning:
>
> If the struct srcu_struct is dynamically allocated, then
> cleanup_srcu_struct() must be called before it is freed ... the
> caller must take care to ensure that all SRCU read-side critical
> sections have completed (and that no more will commence) before
> calling cleanup_srcu_struct().
>
> synchronize_srcu() will (obviously) wait for the grace period to
> complete. Calling it will shut up the warning for sure, most of the time.
>
> The required sequence of events is in here:
>
> > https://lore.kernel.org/lkml/1492472726-3841-4-git-send-email-paulmck@linux.vnet.ibm.com/
I'll add "Link:" for this to the final fix. It's a good reference.
> I suspect that the mmu notifier's synchronize_srcu() is run in parallel
> very close to when cleanup_srcu_struct() is called. This violates the
> "prevent any further calls to synchronize_srcu" rule.
>
> So, while I suspect that adding a synchronize_srcu() is *part* of the
> correct solution, I'm still not convinced that the
> sgx_mmu_notifier_release() code is correct.
What Sean suggested in private discussion, i.e. using kref_get() in the MMU
notifier AFAIK should be enough to do the necessary serialization.
/Jarkko
prev parent reply other threads:[~2021-01-27 17:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 1:46 [PATCH v4] x86/sgx: Fix the call order of synchronize_srcu() in sgx_release() jarkko
2021-01-15 7:18 ` Borislav Petkov
2021-01-16 5:12 ` Jarkko Sakkinen
2021-01-18 18:57 ` Borislav Petkov
2021-01-20 14:43 ` Jarkko Sakkinen
2021-01-20 17:34 ` Dave Hansen
2021-01-21 0:26 ` Jarkko Sakkinen
2021-01-22 18:20 ` Haitao Huang
2021-01-20 17:35 ` Sean Christopherson
2021-01-21 0:29 ` Jarkko Sakkinen
2021-01-21 1:19 ` Dave Hansen
2021-01-21 12:55 ` Jarkko Sakkinen
2021-01-21 18:19 ` Dave Hansen
2021-01-22 16:56 ` Dave Hansen
2021-01-23 8:58 ` Jarkko Sakkinen
2021-01-25 15:49 ` Dave Hansen
2021-01-27 17:31 ` Jarkko Sakkinen [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=YBGji9ZAS23r35Vo@kernel.org \
--to=jarkko@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=haitao.huang@intel.com \
--cc=haitao.huang@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jethro@fortanix.com \
--cc=kai.huang@intel.com \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--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 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.