From patchwork Mon Feb 1 10:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 374229 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1120356jah; Mon, 1 Feb 2021 02:05:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXnxebxPIoHX1Q9jW9au7p3/1orh7tiSEzwGz9wnqofmVB/C1R8/izS2supBbVsV8xg0aT X-Received: by 2002:a05:6402:100b:: with SMTP id c11mr17886303edu.193.1612173900526; Mon, 01 Feb 2021 02:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612173900; cv=none; d=google.com; s=arc-20160816; b=QKVRyzO/+QWStQyhbDHzg8mPMfPNWN5rafm+QI4upxFTk196oCkFhQpQNYwUPCtHHv 72vBbbFmAArwRg2OwDSTi2yEjDtJWLI7ul3uVHAIA5MWvkWkA0FKgzvI8er4V099y5xx juFLSiPmkz24Ts/+eVzuYlgQpA5H0c5wi+2Dlqtw110gLGF0xp/Gn5MLbXtSg/h5Qrk1 bxbN91q3QwFmlKpOXHiMCd/87Z99mbwP4IFyyVGQkx5wX94Vx9qb0sNrqIEOd6oaCkej 9xt9ZOlnntZpQt2NwLMDUbU/jsY93+xH0fm8rPkCyaFadFirM7se4aivvuPWtGOgBMuV mh2w== 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 :dkim-signature; bh=qqBoT1xpWEYMKezlYyKQ2zkhv0Ilyy8rHIYG+0h8Im8=; b=AI3VaNTGKD65a4Pv5U1SlfTSf1AdnUiDJoLVROzMiQlhkUWzqsL6roFPlVA5gFbc61 7myW34Kiptzr5Mh8RGZUrSHAcEqIE4jQNAUt1t3l7VJW0IBk44n8PxL1scMWTMwt6Zyu DR60elzwB76Mr2ffOPn/LNG0zfF9cq44zcC0NTtmEFqaBEEtAXqszQ15eCS0OO0KKcMC 32lqBqu+pMSRPVvPtDY/xizdwxOQHCveaQuYx7q3kizz9IoF1FUJqHak4eDhHR85+Tf4 FYF7LBhLfwF1WFAVVEgyz1WKodDQaz2Hrz1NA5RhY4Be+kThXJcnhrHlu6H3JxRXt0ck TYkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZVSw6E8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si13120787ejl.643.2021.02.01.02.05.00; Mon, 01 Feb 2021 02:05:00 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linaro.org header.s=google header.b=VZVSw6E8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbhBAKDl (ORCPT + 13 others); Mon, 1 Feb 2021 05:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbhBAKDi (ORCPT ); Mon, 1 Feb 2021 05:03:38 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4B6C061788 for ; Mon, 1 Feb 2021 02:02:18 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id p15so15827322wrq.8 for ; Mon, 01 Feb 2021 02:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qqBoT1xpWEYMKezlYyKQ2zkhv0Ilyy8rHIYG+0h8Im8=; b=VZVSw6E8CrBMDpWIroh7AP3ijX6WSF/iNqU7a3OsFxWDE0C7NN8ad06UubkFhbSf/P lQ7oLzLCLKTTf9lN7OtY4wHQP7Mb+Fz5x1RjWlODXgfdFRBd80r42g9lJgS9BlNq68bu Fj0NWOAWoAZAli//1fi/8NttxABhPJcroBYktMSX07jPfzFzQvjF666VbzibrVmaZrOE lbosIeCcY5GXi1PrXa5hGUrE2YJEcGMPJogSmB1lf2eNI+BlaC14clUDpe8qfqtOZpdR 9BH6Bd14T2l6x8BcXaMfLaRXHikK9jwM5HSNK9rSf+AbYjxzj7lrXr2IbJVZFcQe/KJM gJBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qqBoT1xpWEYMKezlYyKQ2zkhv0Ilyy8rHIYG+0h8Im8=; b=eIeJXIQ6L+Fwf1aoY4BErFxkqp+wG6e7B8hTIqDItKE8XDAfmFeoJgsprIYmIiVvWE 9ucFBkq22b4RbdMBfA2L9LYDXtxpqTNpg7GWkE9xu8Y50o1yI+3E6SCRN4yBroJnnV7R fMjtE6xxW/iDAj1ltyOIkr60fb4qGpvRK3qeKEwL+ooq5O7w+tCtH+6Ma1sxN9EY4cTq fPwEB6/bJ0muc4WeAlt8Sv3fXxtivF1Zawkh2cR0PZO/HRTwPflCv4pJxnMiU8//Go26 xeO1cKL4s+Y2365TyOgl4q+qwFal8SVAL79p1co9QT/Br1q/bARF5MqoP9nt8wAnRme5 VzYg== X-Gm-Message-State: AOAM530VRrM17gzCLRFFXAH6+Iklg4RE+9F1OBbQt2pP+RZNrASMs5y5 EfixULX21BcAQwDzzeJZKy7zmHEchLHkCAxZ X-Received: by 2002:a5d:5283:: with SMTP id c3mr16682221wrv.319.1612173734636; Mon, 01 Feb 2021 02:02:14 -0800 (PST) Received: from dell.default ([91.110.221.188]) by smtp.gmail.com with ESMTPSA id p15sm26151387wrt.15.2021.02.01.02.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 02:02:14 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Greg Kroah-Hartman , Lee Jones Subject: [PATCH 05/12] futex: Split futex_mm_release() for exit/exec Date: Mon, 1 Feb 2021 10:01:36 +0000 Message-Id: <20210201100143.2028618-6-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201100143.2028618-1-lee.jones@linaro.org> References: <20210201100143.2028618-1-lee.jones@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thomas Gleixner commit 150d71584b12809144b8145b817e83b81158ae5f upstream. To allow separate handling of the futex exit state in the futex exit code for exit and exec, split futex_mm_release() into two functions and invoke them from the corresponding exit/exec_mm_release() callsites. Preparatory only, no functional change. Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20191106224556.332094221@linutronix.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones --- include/linux/futex.h | 6 ++++-- kernel/fork.c | 5 ++--- kernel/futex.c | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/include/linux/futex.h b/include/linux/futex.h index a0de6fe28e00b..063a5cd00d770 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -98,13 +98,15 @@ static inline void futex_exit_done(struct task_struct *tsk) tsk->futex_state = FUTEX_STATE_DEAD; } -void futex_mm_release(struct task_struct *tsk); +void futex_exit_release(struct task_struct *tsk); +void futex_exec_release(struct task_struct *tsk); long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3); #else static inline void futex_init_task(struct task_struct *tsk) { } -static inline void futex_mm_release(struct task_struct *tsk) { } static inline void futex_exit_done(struct task_struct *tsk) { } +static inline void futex_exit_release(struct task_struct *tsk) { } +static inline void futex_exec_release(struct task_struct *tsk) { } #endif #endif diff --git a/kernel/fork.c b/kernel/fork.c index ad9dbbf03d7bc..91349fd3e162d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1084,9 +1084,6 @@ static int wait_for_vfork_done(struct task_struct *child, */ static void mm_release(struct task_struct *tsk, struct mm_struct *mm) { - /* Get rid of any futexes when releasing the mm */ - futex_mm_release(tsk); - uprobe_free_utask(tsk); /* Get rid of any cached register state */ @@ -1121,11 +1118,13 @@ static void mm_release(struct task_struct *tsk, struct mm_struct *mm) void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm) { + futex_exit_release(tsk); mm_release(tsk, mm); } void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm) { + futex_exec_release(tsk); mm_release(tsk, mm); } diff --git a/kernel/futex.c b/kernel/futex.c index 51bbe57bb14ac..902ce420c4ba0 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3269,7 +3269,7 @@ static void exit_robust_list(struct task_struct *curr) curr, pip); } -void futex_mm_release(struct task_struct *tsk) +void futex_exec_release(struct task_struct *tsk) { if (unlikely(tsk->robust_list)) { exit_robust_list(tsk); @@ -3287,6 +3287,11 @@ void futex_mm_release(struct task_struct *tsk) exit_pi_state_list(tsk); } +void futex_exit_release(struct task_struct *tsk) +{ + futex_exec_release(tsk); +} + long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3) {