Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 1 Apr 2019 15:28:35 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Alan Stern' <>, Oleg Nesterov <>
CC: "Paul E. McKenney" <>, Jann Horn <>,
	Joel Fernandes <>, Kees Cook <>,
	"Eric W. Biederman" <>, LKML
	<>, Android Kernel Team
	<>, Kernel Hardening
	<>, Andrew Morton
	<>, Matthew Wilcox <>, "Michal
 Hocko" <>, "Reshetova, Elena" <>
Subject: RE: [PATCH] Convert struct pid count to refcount_t

From: Alan Stern
> Sent: 29 March 2019 19:45
> There is a big difference between WRITE_ONCE() and plain assignment.
> Given "WRITE_ONCE(X, 2)", the compiler will emit a simple store
> instruction.  But given "X = 2", the compiler is allowed to emit
> instructions equivalent to:
> 	if (X != 2)
> 		X = 2;

Worse for you, it can also emit:
	X = 0;
	X = 2;

Many years ago I fell foul of a compiler (not C) that implemented
a write to a 2 bit wide bitfield as:
	X &= ~3
	X |= value
even when 'value' was a compile time constant of 3.
Took a while to find out why the linked list got f*cked.


Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

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.