Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190701182519.GA125555@google.com>
Date: Mon, 1 Jul 2019 14:25:19 -0400
From: Joel Fernandes <joel@...lfernandes.org>
To: Jann Horn <jannh@...gle.com>
Cc: kernel list <linux-kernel@...r.kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Matthew Wilcox <willy@...radead.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Will Deacon <will.deacon@....com>,
	"Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>,
	Elena Reshetova <elena.reshetova@...el.com>,
	Kees Cook <keescook@...omium.org>,
	kernel-team <kernel-team@...roid.com>,
	Kernel Hardening <kernel-hardening@...ts.openwall.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Michal Hocko <mhocko@...e.com>, Oleg Nesterov <oleg@...hat.com>,
	Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH v2] Convert struct pid count to refcount_t

On Mon, Jul 01, 2019 at 07:48:26PM +0200, Jann Horn wrote:
> On Fri, Jun 28, 2019 at 9:35 PM Joel Fernandes (Google)
> <joel@...lfernandes.org> wrote:
> > struct pid's count is an atomic_t field used as a refcount. Use
> > refcount_t for it which is basically atomic_t but does additional
> > checking to prevent use-after-free bugs.
> [...]
> >  struct pid
> >  {
> > -       atomic_t count;
> > +       refcount_t count;
> [...]
> > diff --git a/kernel/pid.c b/kernel/pid.c
> > index 20881598bdfa..89c4849fab5d 100644
> > --- a/kernel/pid.c
> > +++ b/kernel/pid.c
> > @@ -37,7 +37,7 @@
> >  #include <linux/init_task.h>
> >  #include <linux/syscalls.h>
> >  #include <linux/proc_ns.h>
> > -#include <linux/proc_fs.h>
> > +#include <linux/refcount.h>
> >  #include <linux/sched/task.h>
> >  #include <linux/idr.h>
> >
> > @@ -106,8 +106,7 @@ void put_pid(struct pid *pid)
> 
> init_struct_pid is defined as follows:
> 
> struct pid init_struct_pid = {
>         .count          = ATOMIC_INIT(1),
> [...]
> };
> 
> This should be changed to REFCOUNT_INIT(1).
> 
> You should have received a compiler warning about this; I get the
> following when trying to build with your patch applied:

Thanks. Andrew had fixed this in patch v1 but Linus dropped it for other
reasons. Anyway, I should have fixed this in my resubmit.

Sorry, I'll fix and resend!

 - Joel


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.