Received: by 10.223.185.116 with SMTP id b49csp2370920wrg; Thu, 15 Feb 2018 10:33:15 -0800 (PST) X-Google-Smtp-Source: AH8x227lkNtQDWOfTaO0GWl/gdHTtok5xD+IF0/3k4lSGAQji3F3w9vg1kDH3xgia9TVQJyFGJm0 X-Received: by 10.99.95.81 with SMTP id t78mr2979514pgb.380.1518719595302; Thu, 15 Feb 2018 10:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518719595; cv=none; d=google.com; s=arc-20160816; b=DU3KyLhSIliWbOBQAuwJG+TscwbD9MuUVxIHRLUrnZlmDGxRTbN0d/TyODkHpZeEpU Rhw5u7n+7Ptur5He1G6hPRXssQNQq8r2Rezs1TW82dD2sTqU54o5VPFu+sASdBZ3jsyF Aap2ukdaVOsFbL6Kg5c3ddlgr2+9OC0Q8faeZv8g/fbLvCspLtgniDeZHqk+IlE+TZli hfDlOUOq14BhII3bhVNe7Uyz8NMZTiHOZa1u1ZUMJZqH6uGChvbAkkTUhGttn9ONi4HL wGoqgMgtNKQEo7/1/aOicy2IkbPsjAuRcd4id+4S4cF9rZ/jstixP/EkvBsruX24fRpi OwzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GREonjD7eOCWFWEU4DExQOaVVu4M5SuA6Y1wTp54yl0=; b=ejD0jvBP4Mk0HCvicYUd+4LbfJYSlx4Nt8S1GcP1Jy5uhKoPCXwQn8TAakQ7DVAEQ1 2z0igCQAN9VWAYzYOkmblzJ382CnWhHA55J+1rvAo254mjHXdWs2Sfzv0ylREtv2cyWR fcXbT+Z72NFM0OfZmefnWZn1Y6XyptM8IWpK1aY7FckR8+lnAl/mUTK2cxb4AajnV7Hu WLZfDK5sTrEyR2S4efEb5saWQ8huKHPbgyDJWye9dwHlseJWC8T5fbt8pvXrs2stmOT+ hStMMqycUWexdLEtXALKGQejJhkyFyjLE/rQkPdnCU+NKFNiEc8q8uF+WuqgKRsMb66N M4wg== 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 185si4379838pgj.636.2018.02.15.10.32.59; Thu, 15 Feb 2018 10:33:15 -0800 (PST) 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 S1163017AbeBOPY5 (ORCPT + 99 others); Thu, 15 Feb 2018 10:24:57 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52006 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162990AbeBOPYx (ORCPT ); Thu, 15 Feb 2018 10:24:53 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1316CFA3; Thu, 15 Feb 2018 15:24:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov Subject: [PATCH 4.4 100/108] xtensa: fix futex_atomic_cmpxchg_inatomic Date: Thu, 15 Feb 2018 16:17:37 +0100 Message-Id: <20180215151236.305341627@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable 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: Greg Kroah-Hartman --- 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; }