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] [day] [month] [year] [list]
Message-ID: <ad4137be8f8b14f932e6590355d59618c3fbfc9c@linux.dev>
Date: Fri, 25 Apr 2025 05:37:54 +0000
From: "Jiayuan Chen" <jiayuan.chen@...ux.dev>
To: "Christian Brauner" <brauner@...nel.org>, "Oleg Nesterov"
 <oleg@...hat.com>
Cc: linux-kernel@...r.kernel.org, mrpre@....com, mkoutny@...e.com,
 syzbot+adcaa842b762a1762e7d@...kaller.appspotmail.com,
 syzbot+fab52e3459fa2f95df57@...kaller.appspotmail.com,
 syzbot+0718f65353d72efaac1e@...kaller.appspotmail.com, "Andrew Morton"
 <akpm@...ux-foundation.org>, "Lorenzo Stoakes"
 <lorenzo.stoakes@...cle.com>, "Liam R. Howlett"
 <Liam.Howlett@...cle.com>, "Suren Baghdasaryan" <surenb@...gle.com>, "Wei
 Yang" <richard.weiyang@...il.com>, "David Hildenbrand"
 <david@...hat.com>, "Al Viro" <viro@...iv.linux.org.uk>, "Mateusz Guzik"
 <mjguzik@...il.com>, "Joel Granados" <joel.granados@...nel.org>, "Jens
 Axboe" <axboe@...nel.dk>, "Wei Liu" <wei.liu@...nel.org>, "Frederic
 Weisbecker" <frederic@...nel.org>
Subject: Re: [PATCH v1] pid: annotate data-races around pid_ns->pid_allocated

April 24, 2025 at 17:38, "Christian Brauner" <brauner@...nel.org> wrote:

> 
> On Wed, Apr 23, 2025 at 06:38:18PM +0200, Oleg Nesterov wrote:
> 
> > 
> > On 04/23, Jiayuan Chen wrote:
> > 
> >  April 23, 2025 at 21:51, "Oleg Nesterov" <oleg@...hat.com> wrote:
> > 
> >  >
> > 
> >  > On 04/23, Jiayuan Chen wrote:
> > 
> >  >
> > 
> >  > >
> > 
> >  > > Suppress syzbot reports by annotating these accesses using
> > 
> >  > >
> > 
> >  > > READ_ONCE() / WRITE_ONCE().
> > 
> >  > >
> > 
> >  >
> > 
> >  > ...
> > 
> >  >
> > 
> >  > >
> > 
> >  > > --- a/kernel/pid.c
> > 
> >  > >
> > 
> >  > > +++ b/kernel/pid.c
> > 
> >  > >
> > 
> >  > > @@ -122,7 +122,8 @@ void free_pid(struct pid *pid)
> > 
> >  > >
> > 
> >  > > for (i = 0; i <= pid->level; i++) {
> > 
> >  > >
> > 
> >  > > struct upid *upid = pid->numbers + i;
> > 
> >  > >
> > 
> >  > > struct pid_namespace *ns = upid->ns;
> > 
> >  > >
> > 
> >  > > - switch (--ns->pid_allocated) {
> > 
> >  > >
> > 
> >  > > + WRITE_ONCE(ns->pid_allocated, READ_ONCE(ns->pid_allocated) - 1);
> > 
> >  > >
> > 
> >  > > + switch (READ_ONCE(ns->pid_allocated)) {
> > 
> >  > >
> > 
> >  >
> > 
> >  > I keep forgetting how kcsan works, but we don't need
> > 
> >  >
> > 
> >  > READ_ONCE(ns->pid_allocated) under pidmap_lock?
> > 
> >  >
> > 
> >  > Same for other functions which read/modify ->pid_allocated with
> > 
> >  >
> > 
> >  > this lock held.
> > 
> >  >
> > 
> >  > Oleg.
> > 
> >  >
> > 
> >  However, not all places that read/write pid_allocated are locked,
> > 
> >  for example:
> > 
> >  https://web.git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/kernel/pid_namespace.c#n271
> > 
> >  https://web.git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/kernel/fork.c#n2602
> > 
> >  So, in fact, the pidmap_lock is not effective. And if we were to add locks
> > 
> >  to all these places, it would be too heavy.
> > 
> >  
> > 
> >  It seems you misunderstood me. I didn't argue with the lockless READ_ONCE()s
> > 
> >  outside of pidmap_lock.
> > 
> 
> Agreed. We should only add those annotations where they're really
> 
> needed (someone once taught me ;).
>

Thank you for your suggestion, it make sense to me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ