From: Peter Zijlstra <peterz@infradead.org>
To: Qian Cai <cai@lca.pw>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
dbueso@suse.de, juri.lelli@redhat.com,
Waiman Long <longman@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next v2] locking/percpu-rwsem: fix a task_struct refcount
Date: Mon, 6 Apr 2020 16:09:30 +0200 [thread overview]
Message-ID: <20200406140930.GN20730@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <C6D137A2-15A9-49BC-BCE2-DA1202B5AC3A@lca.pw>
On Mon, Apr 06, 2020 at 09:31:18AM -0400, Qian Cai wrote:
>
>
> > On Mar 30, 2020, at 5:30 PM, Qian Cai <cai@lca.pw> wrote:
> >
> > The commit 7f26482a872c ("locking/percpu-rwsem: Remove the embedded
> > rwsem") introduced some task_struct memory leaks due to messing up with
> > a task_struct refcount. At the beginning of
> > percpu_rwsem_wake_function(), it calls get_task_struct(), but if the
> > trylock failed, it will remain in the waitqueue. However, it will run
> > percpu_rwsem_wake_function() again with get_task_struct() to increase
> > the refcount but then only call put_task_struct() once the trylock
> > succeeded.
> >
> > Fix it by adjusting percpu_rwsem_wake_function() a bit to guard against
> > when percpu_rwsem_wait() observing !private, terminating the wait and
> > doing a quick exit() while percpu_rwsem_wake_function() then doing
> > wake_up_process(p) as a use-after-free.
> >
> > Fixes: 7f26482a872c ("locking/percpu-rwsem: Remove the embedded rwsem")
>
> Peter, Ingo, can you take a look at this patch when you have a chance?
I have it queued for urgent, should probably hit tip soon.
next prev parent reply other threads:[~2020-04-06 14:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 21:30 [PATCH -next v2] locking/percpu-rwsem: fix a task_struct refcount Qian Cai
2020-04-06 13:31 ` Qian Cai
2020-04-06 14:09 ` Peter Zijlstra [this message]
2020-04-08 12:20 ` [tip: locking/urgent] locking/percpu-rwsem: Fix " tip-bot2 for Qian Cai
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=20200406140930.GN20730@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=cai@lca.pw \
--cc=dbueso@suse.de \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=will@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