Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2215317imm; Thu, 7 Jun 2018 07:11:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJqeiz3PZscWAyiHYkO0pp7xHi8xL5alHX9WaxxN1KgpZKWKcI8YVwSfILsQFupmMvrk8Y4 X-Received: by 2002:a63:6ec1:: with SMTP id j184-v6mr1748671pgc.332.1528380719644; Thu, 07 Jun 2018 07:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528380719; cv=none; d=google.com; s=arc-20160816; b=QCrAvgNP4S1BomV3WpoHT/Pi1PjiYUZHtwAFDlyowddnZquKjKG+kWcxmwh+MfkG0a 7WYJGNk3BWXr3tTA1P8l6x0z/M0ZAU5/n+Xgx5xvc97n+ox33jJacwEC7AeARDw4BCAF mOFIzdTmMyO40TbeCEMINIO3o5YNkMPjpzdumHvW3bjSUF9ueIIYurxaq/4IjP5gwQvt TqOPcP911WoNhk07rhp4xgg+Yj52Gu2KG+psGpVjiapdJHAFV237kb9uWwpApKZZz8LX 40JqhyfiDYoQmTsB9AX8IhFlkqC4UI6NhFaccm203BNNqzUT1TOx7nMIXy/PhweJkcLs Spxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=nEc5CFd3+ZHnXz0wewoxzg4/TCUYBQCl29dsPY3zDWI=; b=jEWIYtgU3atq0EZ//SWyiY8egwJdpUGNb1Cq6zVx50xVruCqdvSyz0Gvay/4JQw5o2 jbkFyp1FIVuTPEwLNCW41hn8uvgp7OwUzLBLWm4HJtLx0zOJC5Xb+h09z7nzy3/0OZs+ mmObaTRjG3woA3r8Rw2Gau7yOeazNgjmCk4Ier6pBcZBmZFOr4ArE8RGl97Xhx98hodv PkXncsRe0FVyvADDtTa4F3Qp5v3OKdg9+xP14HaimDogDhON+vXi1H9+ELvxiXz4rQg7 rhdA5aeGWMUY3AahdJMlG8cIWSaJ8D4itGHm9c25VurfPOkIj61gFLQ9kr2L85KnhA1E /glw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u29-v6si17690480pfi.96.2018.06.07.07.11.44; Thu, 07 Jun 2018 07:11:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933149AbeFGOJ2 (ORCPT + 99 others); Thu, 7 Jun 2018 10:09:28 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39233 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933003AbeFGOJE (ORCPT ); Thu, 7 Jun 2018 10:09:04 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb4-0005Zl-8k; Thu, 07 Jun 2018 15:09:02 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb1-0002ox-70; Thu, 07 Jun 2018 15:08:59 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Max Filippov" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 096/410] xtensa: fix futex_atomic_cmpxchg_inatomic In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Max Filippov commit ca47480921587ae30417dd234a9f79af188e3666 upstream. Return 0 if the operation was successful, not the userspace memory value. Check that userspace value equals passed oldval, not itself. Don't update *uval if the value wasn't read from userspace memory. This fixes process hang due to infinite loop in futex_lock_pi. It also fixes a bunch of glibc tests nptl/tst-mutexpi*. Signed-off-by: Max Filippov Signed-off-by: Ben Hutchings --- arch/xtensa/include/asm/futex.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) --- a/arch/xtensa/include/asm/futex.h +++ b/arch/xtensa/include/asm/futex.h @@ -109,7 +109,6 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 oldval, u32 newval) { int ret = 0; - u32 prev; if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) return -EFAULT; @@ -120,26 +119,24 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, __asm__ __volatile__ ( " # futex_atomic_cmpxchg_inatomic\n" - "1: l32i %1, %3, 0\n" - " mov %0, %5\n" - " wsr %1, scompare1\n" - "2: s32c1i %0, %3, 0\n" - "3:\n" + " wsr %5, scompare1\n" + "1: s32c1i %1, %4, 0\n" + " s32i %1, %6, 0\n" + "2:\n" " .section .fixup,\"ax\"\n" " .align 4\n" - "4: .long 3b\n" - "5: l32r %1, 4b\n" - " movi %0, %6\n" + "3: .long 2b\n" + "4: l32r %1, 3b\n" + " movi %0, %7\n" " jx %1\n" " .previous\n" " .section __ex_table,\"a\"\n" - " .long 1b,5b,2b,5b\n" + " .long 1b,4b\n" " .previous\n" - : "+r" (ret), "=&r" (prev), "+m" (*uaddr) - : "r" (uaddr), "r" (oldval), "r" (newval), "I" (-EFAULT) + : "+r" (ret), "+r" (newval), "+m" (*uaddr), "+m" (*uval) + : "r" (uaddr), "r" (oldval), "r" (uval), "I" (-EFAULT) : "memory"); - *uval = prev; return ret; }