From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755823Ab2CEABZ (ORCPT ); Sun, 4 Mar 2012 19:01:25 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:41635 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753934Ab2CEABX convert rfc822-to-8bit (ORCPT ); Sun, 4 Mar 2012 19:01:23 -0500 Authentication-Results: mr.google.com; spf=pass (google.com: domain of jrnieder@gmail.com designates 10.43.51.135 as permitted sender) smtp.mail=jrnieder@gmail.com; dkim=pass header.i=jrnieder@gmail.com Date: Sun, 4 Mar 2012 18:01:13 -0600 From: Jonathan Nieder To: linux-ia64@vger.kernel.org Cc: Michel Lespinasse , Tony Luck , =?utf-8?Q?=C3=89meric?= Maschino , Patrick Baggett , Jakub Jelinek , linux-kernel@vger.kernel.org Subject: [regression] Re: [PATCH 2/3] futex: Sanitize cmpxchg_futex_value_locked API Message-ID: <20120305000112.GA27512@burratino> References: <20110307021127.GB31188@google.com> <20110309112550.GA3050@google.com> <20110311021654.GA26122@google.com> <20110311024851.GC26122@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20110311024851.GC26122@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (reset cc list) Hi, Michel Lespinasse wrote: > This change makes the cmpxchg_futex_value_locked API more similar to the > get_futex_value_locked one, returning an error code and updating the > original value through a reference argument. [...] > Acked-by: Tony Luck [ia64] Émeric Maschino (cc-ed) is experiencing random crashes, X restarts, and so on on Itanium. Bisects to this patch[1]. Patrick Baggett, investigating, wrote[2]: > It doesn't look like the return value (r8) is actually being set beyond > initialized to 0. If there is some ia64 instruction that modifies it, GCC > doesn't know about it from the inline assembly (r8 doesn't appear in the > inputs/outputs list). From looking at the x86 version (agh, inline asm is > hard to parse), it does modify the return value based on whether the > comparison was a success or not, and the return value is certainly used by > the callers. And indeed, pinning that variable to that register (why not "prev" instead?) looks suspicious. Anywhere, here's the potentially problematic patch hunk. Ideas? > --- a/arch/ia64/include/asm/futex.h > +++ b/arch/ia64/include/asm/futex.h > @@ -100,23 +100,26 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) > } > > static inline int > -futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) > +futex_atomic_cmpxchg_inatomic(int *uval, int __user *uaddr, > + int oldval, int newval) > { > if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) > return -EFAULT; > > { > - register unsigned long r8 __asm ("r8"); > + register unsigned long r8 __asm ("r8") = 0; > + unsigned long prev; > __asm__ __volatile__( > " mf;; \n" > " mov ar.ccv=%3;; \n" > "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" > " .xdata4 \"__ex_table\", 1b-., 2f-. \n" > "[2:]" > - : "=r" (r8) > + : "=r" (prev) > : "r" (uaddr), "r" (newval), > "rO" ((long) (unsigned) oldval) > : "memory"); > + *uval = prev; > return r8; > } > } Jonathan [1] https://bugzilla.kernel.org/show_bug.cgi?id=42757 [2] http://thread.gmane.org/gmane.linux.debian.ports.ia64/3121/focus=3123