From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932896AbdHYUpz (ORCPT ); Fri, 25 Aug 2017 16:45:55 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42702 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932836AbdHYUpt (ORCPT ); Fri, 25 Aug 2017 16:45:49 -0400 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> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) 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 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