From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Desnoyers Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs Date: Mon, 2 Jul 2018 19:16:59 -0400 (EDT) Message-ID: <825871008.10839.1530573419561.JavaMail.zimbra@efficios.com> References: <20180702223143.4663-1-mathieu.desnoyers@efficios.com> <415287289.10831.1530572418907.JavaMail.zimbra@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Linus Torvalds Cc: Thomas Gleixner , linux-kernel , linux-api , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk List-Id: linux-api@vger.kernel.org ----- On Jul 2, 2018, at 7:06 PM, Linus Torvalds torvalds@linux-foundation.org wrote: > On Mon, Jul 2, 2018 at 4:00 PM Mathieu Desnoyers > wrote: >> >> Unfortunately, that rseq->rseq_cs field needs to be updated by user-space >> with single-copy atomicity. Therefore, we want 32-bit user-space to initialize >> the padding with 0, and only update the low bits with single-copy atomicity. > > Well... It's actually still single-copy atomicity as a 64-bit value. > > Why? Because it doesn't matter how you write the upper bits. You'll be > writing the same value to them (zero) anyway. > > So who cares if the write ends up being two instructions, because the > write to the upper bits doesn't actually *do* anything. > > Hmm? Are there any kind of guarantees that a __u64 update on a 32-bit architecture won't be torn into something daft like byte-per-byte stores when performed from C code ? I don't worry whether the upper bits get updated or how, but I really care about not having store tearing of the low bits update. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com