From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB906C4363A for ; Wed, 28 Oct 2020 21:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8269A24724 for ; Wed, 28 Oct 2020 21:59:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sTCIRqNf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="z0Gji0gj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729322AbgJ1V7a (ORCPT ); Wed, 28 Oct 2020 17:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729293AbgJ1V70 (ORCPT ); Wed, 28 Oct 2020 17:59:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5607C0613CF; Wed, 28 Oct 2020 14:59:26 -0700 (PDT) Date: Wed, 28 Oct 2020 14:53:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603896832; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bgXvIqLYv72DaF7oICyGH2Ps5zQbCTbcLjc0yNij5h0=; b=sTCIRqNfEqeNvBUmCxWSmTRi2OeEVhkrUAukrBKGiNAvG9K7638Lhrrj3Zkei/ROeJ/SXZ 1GUnk21iNitiCxFI1x+cax1lT+l6iu5iGrACEYb/L3iUSDZdUTkSrrqeZpr47j04CRExg6 Uh7N8B2dytz+e34H5CVjYVsRB9FtxDYLitz7PusjLaTn0/B6V31G9yJlm8s9cZnk0RkEwN GspBjxiZYnMWnpqtC6cCY6t/imOvNa3HGE6c57CQIgJ5mN41gA6R6ryLiQtAg22wYd8Kpy aSZYVGB/n9H47ZzhtTBhT6XNEKE3LOTrByPnwxVcCq22vciNHLgBHzMoQNJ9gQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603896832; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bgXvIqLYv72DaF7oICyGH2Ps5zQbCTbcLjc0yNij5h0=; b=z0Gji0gjVYvBioKIDYLtif2gVuWWHIEEUe48C7TA0PpkpgRgRuQXsAF0cvdLj/V4bDpnqZ KCDCB208VprkbuAw== From: "tip-bot2 for Mateusz Nosek" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] futex: Fix incorrect should_fail_futex() handling Cc: Mateusz Nosek , Thomas Gleixner , x86 , LKML In-Reply-To: <20200927000858.24219-1-mateusznosek0@gmail.com> References: <20200927000858.24219-1-mateusznosek0@gmail.com> MIME-Version: 1.0 Message-ID: <160389683158.397.17433889538041702702.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 Gitweb: https://git.kernel.org/tip/921c7ebd1337d1a46783d7e15a850e12aed2eaa0 Author: Mateusz Nosek AuthorDate: Sun, 27 Sep 2020 02:08:58 +02:00 Committer: Thomas Gleixner CommitterDate: Wed, 28 Oct 2020 15:48:51 +01:00 futex: Fix incorrect should_fail_futex() handling 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 --- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/futex.c b/kernel/futex.c index a587669..39681bf 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1502,8 +1502,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)) {