Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp830731pxb; Tue, 3 Nov 2020 13:47:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCKxUIkFGDKPKQruTTdJ7aMcM8InQ9vyGDt7vQE5ZLE92XxFsruFJW5a7TWedSm+w8Lwaa X-Received: by 2002:a17:906:170f:: with SMTP id c15mr22927304eje.347.1604440062898; Tue, 03 Nov 2020 13:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440062; cv=none; d=google.com; s=arc-20160816; b=edQgJE8dEzCd+a2LLxsw0hzf/Cig5AfC4Cz/vraxyP/PK/nwYnUVAqhZZSjqBFBjSe 61aL/kZxJKLz0o9yAmzv1O0RtpgV60racHwjHpoWEzHjcgd+CMjUKWfSi7uoGQEgBHC2 iJWhVNxfSlPVepWTUS6U2PHzKRCL8wOZz8vJnMR3QlTpc9ficVySSTeo+/+Q2i0J+FdI MpsSvX3pGs9SUEHDIuW75V06zLUf2LyHjoiznqJj0RHGBk25ip52vfev5X72sbT4VLsv liyy4iwawQNruX7Rcn1/mFMi7kd/gcoNAGWdxPk/I5nO3lCTkL0LyUFLy4X4GMF9zVlc JTcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M7PJloYLCFSelpap7BXTOgeLDnwQreGT94y0FdzUIdM=; b=RPpmQL5j77jCA44Nir/G1ELXLD/xJ5OgYXV6GJJAgHkQHWx9hhTA8AlF+SD/04/tO0 +xNQgyq8dzbqIV6xS1yWgnPmQU8FjcvraA+W9jT8zizvTB306RGmny0ZDyFtJJ8oHqHP Nsv2uiduPwPxdFUR/RacMFDaZJszRFCqyHkkq0/hE/4hgijNYA+rCDymuPBMvxOEULwc 8gjRrY2vAZEu2lwqyT1lEOzImN3+2KuK+oyKFUJ3WPa00KhDWHJ20c3SiYZWpSz5x0Fn N4ML7CB6MbfOeMWZcmUsjqxyIYrCE0Gz/jeinuuRB7Lv9F0sYXFORUvvMWGBeha8bnRb SziQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F/CHawK+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si6807044edr.509.2020.11.03.13.47.19; Tue, 03 Nov 2020 13:47:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F/CHawK+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732354AbgKCVpF (ORCPT + 99 others); Tue, 3 Nov 2020 16:45:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:51488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732323AbgKCUx3 (ORCPT ); Tue, 3 Nov 2020 15:53:29 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACA8C2053B; Tue, 3 Nov 2020 20:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436809; bh=dikpX/t8/UCqAf/2m+usr05OjxYuBSYeeLamj5cmjwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/CHawK+YiZdk+fbe+HFeLFn9u+8F2qixwJhhyB7+uNmXEya9iezpVE7GefgZ41AV +pVrK+ETpnatUikSAxNN4ev0o5fUfFnnE+Ede8q2ELeafKIMhOAMNjcqZMlZsd0/OC rmotnCwcWvQ2PKUopCj/pXyzgGJpKxWMK5EMHpYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mateusz Nosek , Thomas Gleixner , Sasha Levin Subject: [PATCH 5.4 020/214] futex: Fix incorrect should_fail_futex() handling Date: Tue, 3 Nov 2020 21:34:28 +0100 Message-Id: <20201103203251.807143878@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mateusz Nosek [ Upstream commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 ] If should_futex_fail() returns true in futex_wake_pi(), then the 'ret' variable is set to -EFAULT and then immediately overwritten. So the failure injection is non-functional. Fix it by actually leaving the function and returning -EFAULT. The Fixes tag is kinda blury because the initial commit which introduced failure injection was already sloppy, but the below mentioned commit broke it completely. [ tglx: Massaged changelog ] Fixes: 6b4f4bc9cb22 ("locking/futex: Allow low-level atomic operations to return -EAGAIN") Signed-off-by: Mateusz Nosek Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20200927000858.24219-1-mateusznosek0@gmail.com Signed-off-by: Sasha Levin --- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/futex.c b/kernel/futex.c index 5660c02b01b05..17fba7a986e0f 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1594,8 +1594,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ */ newval = FUTEX_WAITERS | task_pid_vnr(new_owner); - if (unlikely(should_fail_futex(true))) + if (unlikely(should_fail_futex(true))) { ret = -EFAULT; + goto out_unlock; + } ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval); if (!ret && (curval != uval)) { -- 2.27.0