Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2426854pxb; Tue, 23 Feb 2021 06:53:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5aI2XUSvHQT56ssl+pnKYLBQn8na3rpdMFNIpHAtC0wlLaLwowaA+ABCKZxYAOor8O12k X-Received: by 2002:a17:907:728b:: with SMTP id dt11mr26254383ejc.321.1614092039043; Tue, 23 Feb 2021 06:53:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614092039; cv=none; d=google.com; s=arc-20160816; b=ywu+qOxE6PCwqrcA9TkHh52TiOybynlXeo50PVyERFRlozRXVHsyrhFbARlgheuzAe nGt0UkNPPEYjFeI9uuXOl+YLSmRXLEKjPAtsxGPt1EuDpD4oRR2Y+fVHLeMLMyHV7H8h WrTGoi8N+hyqDbSs9dUbIZXQWodLDJs6lkS2V4Jdkm4zE35C0EKnmsUQ6zyzQoow6bB4 VlEmkSdgHhHZzLDyktveEWpL7cMppdHy/AkqKSKe4BTTOcYGGAjOIjhTx9jqiUYj13MQ V1ponedx8F03HYoBMECCZHIT15w+KzR/PKHUL9/gyJTutRrndR4ahz+dF0dZfgBzsq2m yglw== 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=2/iptjsMR0PixRJ6lZT8v0gVXqrPfKxCEHsARV6HvIU=; b=pNxozSs1HB/7baiIGWHFTo0fK3da8banFgfX32H7/szDa8NME8vqUH3Q+5knIhedtz ezYJNdU34M57aHartUKvImIu7Jc0sxPgaGFIH1tFfDq4sgFxPeOw00j8BKPQjmJ2D6vM eVS2q0o9C496ltYtOJgUl8raK6QJI+8iOgh+Lwji5ZDMihkKs84Oyi873XMsmkpjscF4 0LYOBecZe+MS3JxEQaOh9f8KQ4AAERDtK9uHsHc9ug/FvoDG004xAi8hCraNDNvTpxB/ p1BbeRn7NUCHhb0GOLS+Xltn5qJfvJoa4zJJ7OaXj6FMU4JlGVRYrf7vx8bu+3Fgz2/f 4D+Q== 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 w25si3911761ejy.70.2021.02.23.06.53.30; Tue, 23 Feb 2021 06:53:59 -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 S233035AbhBWOfr (ORCPT + 99 others); Tue, 23 Feb 2021 09:35:47 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:12947 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbhBWOfl (ORCPT ); Tue, 23 Feb 2021 09:35:41 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DlM3m0cfWzjPqq; Tue, 23 Feb 2021 22:33:24 +0800 (CST) Received: from code-website.localdomain (10.175.127.227) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Tue, 23 Feb 2021 22:34:33 +0800 From: Zheng Yejian To: , , , CC: , , , Subject: [PATCH 4.9.y 1/1] futex: Fix OWNER_DEAD fixup Date: Tue, 23 Feb 2021 22:41:51 +0800 Message-ID: <20210223144151.916675-2-zhengyejian1@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210223144151.916675-1-zhengyejian1@huawei.com> References: <20210223144151.916675-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: Peter Zijlstra commit a97cb0e7b3f4c6297fd857055ae8e895f402f501 upstream. Both Geert and DaveJ reported that the recent futex commit: c1e2f0eaf015 ("futex: Avoid violating the 10th rule of futex") introduced a problem with setting OWNER_DEAD. We set the bit on an uninitialized variable and then entirely optimize it away as a dead-store. Move the setting of the bit to where it is more useful. Reported-by: Geert Uytterhoeven Reported-by: Dave Jones Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: c1e2f0eaf015 ("futex: Avoid violating the 10th rule of futex") Link: http://lkml.kernel.org/r/20180122103947.GD2228@hirez.programming.kicks-ass.net Signed-off-by: Ingo Molnar 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 b65dbb5d60bb..604d1cb9839d 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2424,9 +2424,6 @@ static int __fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, int err = 0; oldowner = pi_state->owner; - /* Owner died? */ - if (!pi_state->owner) - newtid |= FUTEX_OWNER_DIED; /* * We are here because either: @@ -2484,6 +2481,9 @@ static int __fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, } newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; + /* Owner died? */ + if (!pi_state->owner) + newtid |= FUTEX_OWNER_DIED; if (get_futex_value_locked(&uval, uaddr)) goto handle_fault; -- 2.25.4