From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757567AbbJIK0A (ORCPT ); Fri, 9 Oct 2015 06:26:00 -0400 Received: from www.linutronix.de ([62.245.132.108]:36751 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752256AbbJIKZ6 (ORCPT ); Fri, 9 Oct 2015 06:25:58 -0400 Date: Fri, 9 Oct 2015 11:25:09 +0100 (IST) From: Thomas Gleixner To: Hans Zuidam cc: Jaccon Bastiaansen , x86@kernel.org, mingo@redhat.com, "H. Peter Anvin" , Peter Zijlstra , "linux-kernel@vger.kernel.org" , stable@vger.kernel.org, Linus Torvalds Subject: Re: [RFC]: Possible race condition in kernel futex code In-Reply-To: <4387EFE3-55AB-433B-83E1-2AFC413C7B9A@online.nl> Message-ID: References: <4387EFE3-55AB-433B-83E1-2AFC413C7B9A@online.nl> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hans, On Fri, 9 Oct 2015, Hans Zuidam wrote: > On 9 okt. 2015, at 11:06, Thomas Gleixner wrote: > > You cannot use an explicit 32bit read. We need an access which > > handles the fault gracefully. > > The reason for the explicit read suggestion is to avoid the > _builtin_constant_p() in __copy_from_user_nocheck(). The GCC manual > says that there may be situations where it returns 0 even though the > argument is a constant. That's insane at best. > Although none of the compiler/kernel combinations we have tried > showed this happening, we think it is probably better to be safe > than sorry. So we would need something like: futex_copy_from_user() which can be mapped to __copy_from_user_inatomic() first. Then go through all architectures and the asm-generic stuff and provide the specific variants which are guaranteed to use a 32bit access. I really prefer that we don't have to do that and the compiler people get their act together and fix that _builtin_constant_p() thingy. Thanks, tglx