From patchwork Mon Mar 1 16:13:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 390192 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=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 04888C433E0 for ; Mon, 1 Mar 2021 16:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4B176502D for ; Mon, 1 Mar 2021 16:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234967AbhCAQmv (ORCPT ); Mon, 1 Mar 2021 11:42:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:39700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbhCAQfw (ORCPT ); Mon, 1 Mar 2021 11:35:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0FD6964F73; Mon, 1 Mar 2021 16:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614615975; bh=WNCAVJ/vKWgsoYvC6iBp3ixDnLPffgkpsBXKWvHyhE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDcB5NFif/RKALqbInoGhMGxFyqjnWRqqoQHYQLtcLJ6aylSy7SbNtMFtNA8esfNw lQ98tU3u4VwYx+VDNc+99p7dzByzMRm8OtYzZ6sG1VLoT29ZS45RYjgcBJXZVZ8PWX xYx2bAu8j/1PISvsTDCbwxO/+NxkiYeAy2n9VgNw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Dave Jones , "Peter Zijlstra (Intel)" , Andrew Morton , Linus Torvalds , "Paul E. McKenney" , Thomas Gleixner , Ingo Molnar , Lee Jones , Zheng Yejian Subject: [PATCH 4.9 126/134] futex: Fix OWNER_DEAD fixup Date: Mon, 1 Mar 2021 17:13:47 +0100 Message-Id: <20210301161019.791353827@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161013.585393984@linuxfoundation.org> References: <20210301161013.585393984@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 Reviewed-by: Lee Jones Signed-off-by: Zheng Yejian Signed-off-by: Greg Kroah-Hartman --- kernel/futex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2424,9 +2424,6 @@ static int __fixup_pi_state_owner(u32 __ 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 @@ retry: } 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;