Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1476858pxb; Mon, 22 Feb 2021 03:03:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5xAxlWOhC9V/nE4R8IT+3c0ypi2kTiJVgXfapQwheIRwgjZuEJNCCq+tmX/6eMhM7plCA X-Received: by 2002:a05:6402:31a5:: with SMTP id dj5mr9334635edb.388.1613991789310; Mon, 22 Feb 2021 03:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613991789; cv=none; d=google.com; s=arc-20160816; b=ZZ7hlPZAPcEbXo++HF1fPCYHLLE0cswpaVbnF46FdujvbAR/jDZ6MTs4G2YlHpDfLf iQl2GgxRDyyMsUSqGtldOAUK7FLxNZJNwO4Ro13iIaHPBDrdt130mnf20BvqQztCoJpX VT9Mnilu55FPqZlF/9YlmjT3nZ/VdKCU9w0HhDqfRoAYi92rmeUUu3UVD9fOSbZTRPsZ qygZ4Ruamkpjo90PIR99GrPX3n64YdsuVYYnf0HNFDVxdBm27hIm/vx8FH71FuTBreCD AYpzFAz5l4maM5DhQ1y3VgQJPGaxfN5dXm5CSoN/NMI/s0WM/TFoBV92EMjkz7HB6dNP UCGQ== 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=dr1pCPs3j5CBPwOnqAB/pCMd0Rp5xsSyjSLUGS0C7Q4=; b=z5+PBGlaGbnoYXkzuJnZIx/hsXHgaJRGDjUWsUBAF8AduuLSXjXJSh+rbDNFVL5rUP tBWqc48i0QCEZ6kjFYs1Pi8H4lq/jc4e8B/zaFlMLEMKPWIRP2fE4F0FXFAUcZ7j5gYu +h7cUeajagHe5RccUuoFfbr1KUEvK56POCRpfh+vKXbHnJmOZgPz8lKlRt3+Zcu8HkN6 dZr6j8wxievlANzgImSjqjruWBFMabFrX9N81+BmVOv3Xn4+4fyMLG2rkacj6xguueUj Cf39r91A7XcVK2eEtZIXOnyw5C7ce3sa+GLY5DEd1dGfesXctbp+2mfSh0vYb/gceqCy 7hyA== 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 v17si11994535ejy.545.2021.02.22.03.02.47; Mon, 22 Feb 2021 03:03:09 -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 S230433AbhBVK7e (ORCPT + 99 others); Mon, 22 Feb 2021 05:59:34 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:13367 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhBVK7R (ORCPT ); Mon, 22 Feb 2021 05:59:17 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DkfJW3WLxz7ny3; Mon, 22 Feb 2021 18:56:59 +0800 (CST) Received: from code-website.localdomain (10.175.127.227) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 22 Feb 2021 18:58:23 +0800 From: Zheng Yejian To: , , CC: , , , Subject: [PATCH 4.9.257 1/1] futex: Fix OWNER_DEAD fixup Date: Mon, 22 Feb 2021 19:05:42 +0800 Message-ID: <20210222110542.3531596-2-zhengyejian1@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210222110542.3531596-1-zhengyejian1@huawei.com> References: <20210222110542.3531596-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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 83db5787c67e..7cb2baa9446a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2283,10 +2283,6 @@ static int __fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, oldowner = pi_state->owner; - /* Owner died? */ - if (!pi_state->owner) - newtid |= FUTEX_OWNER_DIED; - /* * We are here because either: * @@ -2344,6 +2340,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