[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200406140930.GN20730@hirez.programming.kicks-ass.net>
Date: Mon, 6 Apr 2020 16:09:30 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Qian Cai <cai@....pw>
Cc: Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
dbueso@...e.de, juri.lelli@...hat.com,
Waiman Long <longman@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next v2] locking/percpu-rwsem: fix a task_struct refcount
On Mon, Apr 06, 2020 at 09:31:18AM -0400, Qian Cai wrote:
>
>
> > On Mar 30, 2020, at 5:30 PM, Qian Cai <cai@....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.
Powered by blists - more mailing lists