From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a01:7a0:2:106d:700::1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xfCqG0RM0zDqYV for ; Sat, 26 Aug 2017 06:45:45 +1000 (AEST) Date: Fri, 25 Aug 2017 22:43:41 +0200 (CEST) From: Thomas Gleixner To: Will Deacon cc: Jiri Slaby , mingo@redhat.com, dvhart@infradead.org, peterz@infradead.org, linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Catalin Marinas , Richard Kuo , Tony Luck , Fenghua Yu , Michal Simek , Ralf Baechle , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Martin Schwidefsky , Yoshinori Sato , Rich Felker , "David S. Miller" , "H. Peter Anvin" , Chris Zankel , Max Filippov , Arnd Bergmann , x86@kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@linux-mips.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org Subject: Re: [PATCH v2 1/1] futex: remove duplicated code and fix UB In-Reply-To: <20170824094756.GA6346@arm.com> Message-ID: References: <20170824073105.3901-1-jslaby@suse.cz> <20170824094756.GA6346@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, 24 Aug 2017, Will Deacon wrote: > On Thu, Aug 24, 2017 at 09:31:05AM +0200, Jiri Slaby wrote: > > +static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr) > > +{ > > + unsigned int op = (encoded_op & 0x70000000) >> 28; > > + unsigned int cmp = (encoded_op & 0x0f000000) >> 24; > > + int oparg = sign_extend32((encoded_op & 0x00fff000) >> 12, 12); > > + int cmparg = sign_extend32(encoded_op & 0x00000fff, 12); > > + int oldval, ret; > > + > > + if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) { > > + if (oparg < 0 || oparg > 31) > > + return -EINVAL; > > + oparg = 1 << oparg; > > + } > > + > > + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) > > + return -EFAULT; > > + > > + ret = arch_futex_atomic_op_inuser(op, oparg, &oldval, uaddr); > > + if (ret) > > + return ret; > > We could move the pagefault_{disable,enable} calls here, and then remove > them from the futex_atomic_op_inuser callsites elsewhere in futex.c Correct, but we can do that after getting this in. Thanks, tglx