From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Linux List Kernel Mailing <linux-kernel@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>,
Jann Horn <jannh@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andrea Parri <parri.andrea@gmail.com>,
Andrew Hunter <ahh@google.com>, Andy Lutomirski <luto@kernel.org>,
Avi Kivity <avi@scylladb.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Boqun Feng <boqun.feng@gmail.com>,
Dave Watson <davejwatson@fb.com>, David Sehr <sehr@google.com>,
Greg Hackmann <ghackmann@google.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Maged Michael <maged.michael@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Paul Mackerras <paulus@samba.org>,
Russell King <linux@armlinux.org.uk>,
Will Deacon <will.deacon@arm.com>,
stable@vger.kernel.org
Subject: Re: [RFC PATCH] Fix: membarrier: racy access to p->mm in membarrier_global_expedited()
Date: Mon, 28 Jan 2019 12:46:11 -0800 [thread overview]
Message-ID: <20190128204611.GB4240@linux.ibm.com> (raw)
In-Reply-To: <CAHk-=wjmpfXak0pQVu8dZrk2Oma3OxtEoBHfwCAruu0xpSMN4A@mail.gmail.com>
On Mon, Jan 28, 2019 at 12:27:03PM -0800, Linus Torvalds wrote:
> On Mon, Jan 28, 2019 at 10:27 AM Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> wrote:
> >
> > Jann Horn identified a racy access to p->mm in the global expedited
> > command of the membarrier system call.
> >
> > The suggested fix is to hold the task_lock() around the accesses to
> > p->mm and to the mm_struct membarrier_state field to guarantee the
> > existence of the mm_struct.
>
> Hmm. I think this is right. You shouldn't access another threads mm
> pointer without proper locking.
>
> That said, we *could* make the mm_cachep be SLAB_TYPESAFE_BY_RCU,
> which would allow speculatively reading data off the mm pointer under
> RCU. It might not be the *right* mm if somebody just did an exit, but
> for things like this it shouldn't matter.
That sounds much simpler and more effective than the contention-reduction
approach that I suggested. ;-)
Thanx, Paul
> But if this is the only case that might care, it sounds like just
> doing the proper locking is the right approach.
>
> Linus
>
next prev parent reply other threads:[~2019-01-28 20:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 18:26 [RFC PATCH] Fix: membarrier: racy access to p->mm in membarrier_global_expedited() Mathieu Desnoyers
2019-01-28 20:27 ` Linus Torvalds
2019-01-28 20:46 ` Paul E. McKenney [this message]
2019-01-28 21:07 ` Mathieu Desnoyers
2019-01-28 21:26 ` Paul E. McKenney
2019-01-28 21:33 ` Jann Horn
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=20190128204611.GB4240@linux.ibm.com \
--to=paulmck@linux.ibm.com \
--cc=ahh@google.com \
--cc=avi@scylladb.com \
--cc=benh@kernel.crashing.org \
--cc=boqun.feng@gmail.com \
--cc=davejwatson@fb.com \
--cc=ghackmann@google.com \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luto@kernel.org \
--cc=maged.michael@gmail.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=parri.andrea@gmail.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=sehr@google.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox