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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150918144115.GA14155@redhat.com>
Date:	Fri, 18 Sep 2015 16:41:15 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Dmitry Vyukov <dvyukov@...gle.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Will Deacon <will.deacon@....com>,
	"ebiederm@...ssion.com" <ebiederm@...ssion.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...nel.org>,
	Paul McKenney <paulmck@...ux.vnet.ibm.com>,
	"mhocko@...e.cz" <mhocko@...e.cz>,
	LKML <linux-kernel@...r.kernel.org>,
	"ktsan@...glegroups.com" <ktsan@...glegroups.com>,
	Kostya Serebryany <kcc@...gle.com>,
	Andrey Konovalov <andreyknvl@...gle.com>,
	Alexander Potapenko <glider@...gle.com>,
	Hans Boehm <hboehm@...gle.com>
Subject: Re: [PATCH] kernel: fix data race in put_pid

On 09/18, Dmitry Vyukov wrote:
>
> On Fri, Sep 18, 2015 at 3:44 PM, Oleg Nesterov <oleg@...hat.com> wrote:
> > So I assume that if we have
> >
> >         int X = 0;
> >         atomic_t Y = ATOMIC_INIT(0);
> >
> >         void w(void)
> >         {
> >                 X = 1;
> >                 atomic_inc_return(&Y);
> >         }
> >
> > then
> >
> >         void r(void)
> >         {
> >                 if (atomic_read_ctrl(&Y))
> >                         BUG_ON(X == 0);
> >         }
> >
> > should be correct?  Why?
> >
> > If not then I am even more confused.
>
> This not correct,

Good. because I wasn't able to understand why this could work.

> // thread 1
>                  X = 1;
>                  atomic_inc_return(&Y);
>
> // thread 2
>                  if (atomic_read_ctrl(&Y)) {
>                          X = 2;
>                          BUG_ON(X == 2);
>                   }

Thanks. This makes perfect sense to me.

And then I agree, atomic_read_ctrl() in put_pid() should fix the
theoretical problem.

Perhaps we can add this example to memory-barriers.txt... Although
perhaps it already explains/documents this case. I am afraid to open
it, it is huge and changes too often so every time it looks like a
new document to me ;)

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ