Received: by 10.223.185.116 with SMTP id b49csp2206189wrg; Thu, 15 Feb 2018 08:05:54 -0800 (PST) X-Google-Smtp-Source: AH8x224bvbntTVo4Du7aUNw1SnM4tfjqOUekwug5OV6FDY0e3t001/k4J8+Lh9cLzrBlVmCE+Mrm X-Received: by 2002:a17:902:4222:: with SMTP id g31-v6mr2902780pld.335.1518710754690; Thu, 15 Feb 2018 08:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518710754; cv=none; d=google.com; s=arc-20160816; b=VguK87Gnmii5G0q3t8P4eNRhfhqUoadlRQqDL2xdFd9QeALTjkP0TJujnKYBrJGP3H N+WBbC+tYDCphnAwnK6Zt/6YzX5CWs6tzfLfscBzGx5kIErPIxUFa6Q7KTuth2nRHWF1 i1ZkA+iPilVtlBZf1JwK/QDSxfJCa+TClNLe0em9Rw1zKFd666lnEWbvGdkSCKH/jq4D tep8hUIC1nVPMFPIsPNYcxuzmUu/HVLFQD3n9I9r06xE9wFsxiu9MP4LLcP9xaDsNHiU zWKD7ZPEjsOyU5w5KfQBqg7QW+R3Syi6vD4T+2U8reJJZ9WiDD1PL0+ex8Biq1+y7AE8 gEsA== 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=7eZekoUN+QK+9pok6fMrR/vgIy8wNet0OPks2INjT0I=; b=uFn2T72vBiB3iOJVk7hrOuyegMy8UOqfgOwzNTJpo+giZrHM8L/ddpk7Nsxn8Eu5BO 8bnV8XEbJkIrsa3thTJVbvp5OuBpPl0nzaoN1dQe8QDYR41EQujsvPktKR4LiXkO10/1 vTHcuVhLIJuSm3d2m2VGKP1OoztB/P2OL10g4DCc1DRcrX7BXFXCGU023UGvxW64zsMi A89AEarnZ5qPI/x4dpuBAZvgtvTdBpIZlNY6mem/cqTv8/DxEUj+HvqfkhJGe0zgysUY D7QzJFLVRGK/n24VoBR8fC0w2clemQ+cu/pjxWHH9MbJpGVAyOkk05AEk8HKy2pIfXmz 7fTQ== 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 j12si1631442pgf.622.2018.02.15.08.05.39; Thu, 15 Feb 2018 08:05:54 -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 S1425489AbeBOQCo (ORCPT + 99 others); Thu, 15 Feb 2018 11:02:44 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35734 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424686AbeBOPqc (ORCPT ); Thu, 15 Feb 2018 10:46:32 -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 511A3E3E; Thu, 15 Feb 2018 15:46:31 +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.15 173/202] xtensa: fix futex_atomic_cmpxchg_inatomic Date: Thu, 15 Feb 2018 16:17:53 +0100 Message-Id: <20180215151721.902899501@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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 @@ -92,7 +92,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; @@ -103,26 +102,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; }