Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp21673pxf; Wed, 10 Mar 2021 19:21:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxn2OzggCPbpZJgai773PXBdApTZN+36VVlSEPILd6DLjgeMbdJBLZr/eXMyZMX+T7iXwoi X-Received: by 2002:a17:906:3385:: with SMTP id v5mr961912eja.539.1615432868142; Wed, 10 Mar 2021 19:21:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615432868; cv=none; d=google.com; s=arc-20160816; b=QOhNciP11ZlVUIn4HtYneB96KsK5w6Mpi7pcwH8kc95mOXYrJqigG0w5VCuVQsbq2L 5qlflVZHg9mYKfuCChOHUryyx28sByaiic1rjCjJfeUcUDKJlBbATZ4EwlK33rkNWXBV 78e+DMo77e8azHeHaqcHkm1V6DuEZYDHSCYDWzBF2ptSGl1Jfu2xxg5y7OWpNFsum0Ir PXqRC48LvEeAoASYYQYGb8vfY3Fvb3bLariGanZhf8QzD/Lag17yM2zxEqgvLgQkxu/U tt37dehe3FGNKQAj/QovWNSzRQFbydUndZnKM7WwM1vC+Z5wOrLKcUWtzhDUxhEvdzAs LL3Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PE025SC+DZjxCrguUCwgNtBTuBsB1I+YEeYovbWtERA=; b=B6cqORns65rSr1t+mX6YWeeqc82OPj+T9lcn3hcQeUGzt/D14o12cR/M77QS3KSBDS Vivjl2fsIgCo77wZe1UkLPpdttkfznD/LGWU/l2ipqYLBY/pq6tSUP3PEZUlhcO1o1wQ tC6PplqWYG+97Jk5XokTYjakH2uVE2UgHKcbn6WFP+NihmBMQVSVJePhoL9/8iVrAIaE 0bUG1APwg81xyS9T1rcOHRg7btDjs7Dl6xtImDaTiD/ze9edCZa/UI8QYdLW84V0pj2g E6sgWkRIp9IGYTsxORl0/DanwCJSC1t8CpvfJuGQBx2q9miev2DFKP0/eb5PnDDXWZGR ZuCw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si841602ejx.104.2021.03.10.19.20.45; Wed, 10 Mar 2021 19:21:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbhCKDT2 (ORCPT + 99 others); Wed, 10 Mar 2021 22:19:28 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:13518 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbhCKDTP (ORCPT ); Wed, 10 Mar 2021 22:19:15 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DwvHs2607zNl1q; Thu, 11 Mar 2021 11:16:57 +0800 (CST) Received: from code-website.localdomain (10.175.127.227) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Thu, 11 Mar 2021 11:19:06 +0800 From: Zheng Yejian To: , , , CC: , , , , Subject: [PATCH 4.4 v2 3/3] futex: fix dead code in attach_to_pi_owner() Date: Thu, 11 Mar 2021 11:26:00 +0800 Message-ID: <20210311032600.2326035-4-zhengyejian1@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210311032600.2326035-1-zhengyejian1@huawei.com> References: <20210311032600.2326035-1-zhengyejian1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner This patch comes directly from an origin patch (commit 91509e84949fc97e7424521c32a9e227746e0b85) in v4.9. And it is part of a full patch which was originally back-ported to v4.14 as commit e6e00df182908f34360c3c9f2d13cc719362e9c0 The handle_exit_race() function is defined in commit 9c3f39860367 ("futex: Cure exit race"), which never returns -EBUSY. This results in a small piece of dead code in the attach_to_pi_owner() function: int ret = handle_exit_race(uaddr, uval, p); /* Never return -EBUSY */ ... if (ret == -EBUSY) *exiting = p; /* dead code */ The return value -EBUSY is added to handle_exit_race() in upsteam commit ac31c7ff8624409 ("futex: Provide distinct return value when owner is exiting"). This commit was incorporated into v4.9.255, before the function handle_exit_race() was introduced, whitout Modify handle_exit_race(). To fix dead code, extract the change of handle_exit_race() from commit ac31c7ff8624409 ("futex: Provide distinct return value when owner is exiting"), re-incorporated. Lee writes: This commit takes the remaining functional snippet of: ac31c7ff8624409 ("futex: Provide distinct return value when owner is exiting") ... and is the correct fix for this issue. Fixes: 9c3f39860367 ("futex: Cure exit race") Cc: stable@vger.kernel.org # v4.9.258 Signed-off-by: Xiaoming Ni Reviewed-by: Lee Jones Signed-off-by: Greg Kroah-Hartman Signed-off-by: Zheng Yejian --- kernel/futex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 116766ef7de6..98c65b3c3a00 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1202,11 +1202,11 @@ static int handle_exit_race(u32 __user *uaddr, u32 uval, u32 uval2; /* - * If the futex exit state is not yet FUTEX_STATE_DEAD, wait - * for it to finish. + * If the futex exit state is not yet FUTEX_STATE_DEAD, tell the + * caller that the alleged owner is busy. */ if (tsk && tsk->futex_state != FUTEX_STATE_DEAD) - return -EAGAIN; + return -EBUSY; /* * Reread the user space value to handle the following situation: -- 2.25.4