Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3407839pxf; Mon, 29 Mar 2021 01:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRyruKHWUEwjE+Uigq1tHrrcXVvIwK3iTRkTaF6KIw2imy5tZylPWbW037XduruhP1zHKr X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr27621076ejg.482.1617005220520; Mon, 29 Mar 2021 01:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617005220; cv=none; d=google.com; s=arc-20160816; b=hE/+XioGI7lYPNbrPf208ph8d0TmWEygQWoloFMXLJCqw5piapFRPRes5+PLQPpenb f118uzFfieTm1cnhmAtF3UfbmBZkt2n6RYx8HlK+b7qVZfP2E09OKoKCUenKmPCMHWQi hUm5oKNpjMd82J3zMBedUKM+9TIKp0yOJx4nlQOJrSdL2+YYGIgMCQxaxYiTkHwmYSIG pZnygL0dcCFWBlBToSWNLcN+lfBrJMmES+iQeERx/eCSEKDiZwBXOJ5OwPv0Ap9a+YGd 9xTUu3+lVGqWu1fzxqsWlBTJdii0kzuKip8r3R+6E9SJnuRQd5xVDyzMmsn9/UGb6kmA CGDA== 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=qD1t+hPfMKQOk/KcHo6d3GypQKeYfVNTKW5cVZlVGVk=; b=Cyu1dvX521Qum3QEWZCXzJXRVzTY6dQ359aacWifIdPq8bK+gLpk4VJs04p2/G3FjU a6QKa43EyoQ7mt39yxIqx8dJQjA3ZouVnWPWgj/jRNJY1t0lowQIs5qU4KvhA/yyd9Zd Sjnz6pO2KNhdJaIYTSAIEC6gLRISzW7CR9VnQKpDjcd93EVpB6oeq6BYm7QT00mRtdXA Z7AyJs3cVcQSFaS6bZZ87v2EyMN5AnocOVgaTkUqJPtg1u74/wL4l7iiM5rwbRAp+WBw makuiObgif6WFrakXnDZr4tGq94By7RitoLHnyRxecb8MEyRgONScoAI46H2CRa1h7Cr IXqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gw+zIS9+; 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=pass (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 q18si12043559ejy.55.2021.03.29.01.06.37; Mon, 29 Mar 2021 01:07:00 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=gw+zIS9+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232279AbhC2IFp (ORCPT + 99 others); Mon, 29 Mar 2021 04:05:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:46390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbhC2IDd (ORCPT ); Mon, 29 Mar 2021 04:03:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A84E619CA; Mon, 29 Mar 2021 08:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005012; bh=WWKK9RxNWAXgPCH7HSSLdGqI22JLNNmpgwz5y6Abp2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw+zIS9+1jp61bDfKXikSGxhU91TZuySGQkKoTysDHbit2YfS0r/Pqjj4eYLTJgjs QtXqVMbJNc7M+aJhZaBzsQPp/BWMMavPbi7s+Knk+hEeMuVT6BObo/fpLdrlp3dZty 4RC4uelScmZ49gOvXnHrw4Ul2thIrU5LKxGfxOho= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Mateusz Nosek , Thomas Gleixner , Sasha Levin , Ben Hutchings Subject: [PATCH 4.9 48/53] futex: Fix incorrect should_fail_futex() handling Date: Mon, 29 Mar 2021 09:58:23 +0200 Message-Id: <20210329075609.096873496@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075607.561619583@linuxfoundation.org> References: <20210329075607.561619583@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 commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 upstream. 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 Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1605,8 +1605,10 @@ static int wake_futex_pi(u32 __user *uad */ 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)) {