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: <20230124040611.GD2948950@paulmck-ThinkPad-P17-Gen-1>
Date:   Mon, 23 Jan 2023 20:06:11 -0800
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Alan Stern <stern@...land.harvard.edu>
Cc:     Andrea Parri <parri.andrea@...il.com>,
        Jonas Oberhauser <jonas.oberhauser@...wei.com>,
        Peter Zijlstra <peterz@...radead.org>, will <will@...nel.org>,
        "boqun.feng" <boqun.feng@...il.com>, npiggin <npiggin@...il.com>,
        dhowells <dhowells@...hat.com>,
        "j.alglave" <j.alglave@....ac.uk>,
        "luc.maranget" <luc.maranget@...ia.fr>, akiyks <akiyks@...il.com>,
        dlustig <dlustig@...dia.com>, joel <joel@...lfernandes.org>,
        urezki <urezki@...il.com>,
        quic_neeraju <quic_neeraju@...cinc.com>,
        frederic <frederic@...nel.org>,
        Kernel development list <linux-kernel@...r.kernel.org>
Subject: Re: Internal vs. external barriers (was: Re: Interesting LKMM litmus
 test)

On Mon, Jan 23, 2023 at 09:18:14PM -0500, Alan Stern wrote:
> On Mon, Jan 23, 2023 at 12:16:59PM -0800, Paul E. McKenney wrote:
> > One twist is that the design of both SRCU and RCU are stronger than LKMM
> > requires, as illustrated by the litmus test at the end of this email.
> > 
> > I believe that your proof outline above also covers this case, but I
> > figure that I should ask.
> 
> This test is full of typos, and I guess that one of them seriously 
> affects the meaning, because as far as I can tell the corrected test is 
> allowed.
> 
> > C C-srcu-observed-2
> > 
> > (*
> >  * Result: Sometimes
> >  *
> >  * But please note that the Linux-kernel SRCU implementation is designed
> >  * to provide Never.
> >  *)
> > 
> > {}
> > 
> > P0(int *x, int *y, int *z, struct srcu_struct *s)
> > {
> > 	int r1;
> > 	int r2;
> 
> r2 is never used.
> 
> > 
> > 	r1 = srcu_read_lock(s);
> > 	WRITE_ONCE(*y, 1);
> > 	WRITE_ONCE(*x, 1);
> > 	srcu_read_unlock(s, r3);
> 
> There is no r3; this should be r1.
> 
> > }
> > 
> > P1(int *x, int *y, int *z, struct srcu_struct *s)
> > {
> > 	int r1;
> > 	int r2;
> 
> r2 is never used.
> 
> > 
> > 	r1 = READ_ONCE(*y);
> > 	synchronize_srcu(s);
> > 	WRITE_ONCE(*z, 1);
> > }
> > 
> > P2(int *x, int *y, int *z, struct srcu_struct *s)
> > {
> > 	int r1;
> 
> r1 is never used; it should be r2.
> 
> > 
> > 	WRITE_ONCE(*z, 2);
> > 	smp_mb();
> > 	r2 = READ_ONCE(*x);
> > }
> > 
> > exists (1:r1=1 /\ 1:r2=0 /\ z=1)
> 
> 1:r2 is never used.  Apparently this should 2:r2.
> 
> Given those changes, the test can run as follows: P2 runs to completion, 
> writing z=2 and reading x=0.  Then P0 runs to completion, writing y=1 
> and x=1.  Then P1 runs to completion, reading y=1 and overwriting z=1.

All that and I also messed up by not having "z=2".  :-/

Thank you for looking it over!

But the following one is forbidden, the Result comment below
notwithstanding.  I could have sworn that there was some post-grace-period
write-to-write litmus test that LKMM allowed, but if so, this one is
not it.

------------------------------------------------------------------------

C C-srcu-observed-2

(*
 * Result: Sometimes
 *
 * But please note that the Linux-kernel SRCU implementation is designed
 * to provide Never.
 *)

{}

P0(int *x, int *y, int *z, struct srcu_struct *s)
{
	int r1;

	r1 = srcu_read_lock(s);
	WRITE_ONCE(*y, 1);
	WRITE_ONCE(*x, 1);
	srcu_read_unlock(s, r1);
}

P1(int *x, int *y, int *z, struct srcu_struct *s)
{
	int r1;

	r1 = READ_ONCE(*y);
	synchronize_srcu(s);
	WRITE_ONCE(*z, 1);
}

P2(int *x, int *y, int *z, struct srcu_struct *s)
{
	int r1;

	WRITE_ONCE(*z, 2);
	smp_mb();
	r1 = READ_ONCE(*x);
}

exists (1:r1=1 /\ 2:r1=0 /\ z=2)

------------------------------------------------------------------------

There is the one below, but I am (1) not sure that I have it right,
(2) not immediately certain that the Linux-kernel implementation would
forbid it, (3) not immediately sure that it should be forbidden.

In the meantime, thoughts?

							Thanx, Paul

------------------------------------------------------------------------

C C-srcu-observed-3

(*
 * Result: Sometimes
 *)

{}

P0(int *x, int *y, int *z, struct srcu_struct *s)
{
	int r1;

	r1 = srcu_read_lock(s);
	WRITE_ONCE(*y, 1);
	WRITE_ONCE(*x, 1);
	srcu_read_unlock(s, r1);
}

P1(int *x, int *y, int *z, struct srcu_struct *s)
{
	int r1;

	r1 = READ_ONCE(*y);
	synchronize_srcu(s);
	WRITE_ONCE(*z, 1);
}

P2(int *x, int *y, int *z, struct srcu_struct *s)
{
	WRITE_ONCE(*z, 2);
	smp_mb();
	WRITE_ONCE(*x, 2);
}

exists (1:r1=1 /\ x=2 /\ z=2)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ