lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG48ez11aCEBmO=DM58+Rk7cthW1VWK2O35GWsSJWwQ_fQJ6Fg@mail.gmail.com>
Date:   Mon, 1 Jul 2019 19:48:26 +0200
From:   Jann Horn <jannh@...gle.com>
To:     "Joel Fernandes (Google)" <joel@...lfernandes.org>
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 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:

jannh@...nh2:~/git/foreign/linux$ make kernel/pid.o
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CC      kernel/pid.o
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
 struct pid init_struct_pid = {
                              ^
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ