Re: [RFC][PATCH 0/5] arch: atomic rework

From: Joseph S. Myers
Date: Fri Feb 07 2014 - 12:47:02 EST


On Fri, 7 Feb 2014, Peter Zijlstra wrote:

> There's further problems where things like memset() can write outside
> the specified address range. Examples are memset() using single
> instructions to wipe entire cachelines and then 'restoring' the tail
> bit.

If memset (or any C library function) modifies bytes it's not permitted to
modify in the abstract machine, that's a simple bug and should be reported
as usual. We've made GCC follow that part of the memory model by default
(so a store to a non-bit-field structure field doesn't do a
read-modify-write to a word containing another field, for example) and I
think it's pretty obvious that glibc should do so as well.

(Of course, memset is not an atomic operation, and you need to allow for
that if you use it on an _Atomic object - which is I think valid, unless
the object is also volatile, but perhaps ill-advised.)

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