From patchwork Mon Feb 1 15:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 374263 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1383107jah; Mon, 1 Feb 2021 07:16:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9/VCdGEjzMcHcf6YLI67eLvEMT9c7CR3BgshWjcTF2so3qKZFuGp3VcP73nsBL88+g+XH X-Received: by 2002:adf:9261:: with SMTP id 88mr18559889wrj.227.1612192568390; Mon, 01 Feb 2021 07:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612192568; cv=none; d=google.com; s=arc-20160816; b=N1FSxSiTO3zojlSIC7nOf6gpNBrzRJpZghkmQTRCdhX7OGO13VGXWzDSQdEy+yy7yV a8JfSmjRRxhYIRBdLwkuFTbtqAmre0pNIR2V1UgG2fw9vMzkJ5uRbqSEwA5DiOWVCsCv wVRGUvGEWDCiG+fTXkWlZ+bT0gkLrj41LQL309NJmXL5qIbCg/dP32UtMK7iGjP2y0MY iR9fYAOUlAPMJb/AKrUPqH2AV8DYrJtmTjKedNwJvEIGctXBnYK85ClRZvsOdpOxvKsp 043QFhuUugyoP+oG9+FDMXb4iAxJrokF605/fY0SIQdecg8i3+Snzd5Q+PhamlQNk3/q 8YtA== 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=Iu4YQ/UttuQPFJ7M1Rq64N1axTPYV12HexbBC2SJPVQ=; b=LecqVJtNoDXvz+RCWv2836IViDEySbgENRG91irxYRKRz7aBTmVZri4kw+Rx7Ob1lr sK8rMcfC6+28tm9SwDrGsHZl0/7d5Bdx5onAvOVpIcnZBAd17jO4ATqQ6NbqH+72GmX+ y8zfLBSkNJ8lfdU9GBh+VICzYgFTdIYc/D/G+cCG6IibA8WvkJN7rMpUrwq14ZTbwRwS 5jLCSKUhP977rn8+5VQXbCqJBvMtzJtn+k2QaMfAbL20Sb7wWAwTe8I3jVRhVvRmZOTE cen9Czd/2vxpyddTeavslS54XOZMaKsomGTAv79mtClIFCdxaZRh55t2WnrvEjuyQHlh mCcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T+hbEweK; 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 f29si11574766edj.297.2021.02.01.07.16.08; Mon, 01 Feb 2021 07:16:08 -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=T+hbEweK; 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 S230437AbhBAPOt (ORCPT + 13 others); Mon, 1 Feb 2021 10:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbhBAPOW (ORCPT ); Mon, 1 Feb 2021 10:14:22 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F0CC06174A for ; Mon, 1 Feb 2021 07:13:41 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id e15so13486797wme.0 for ; Mon, 01 Feb 2021 07:13:40 -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=Iu4YQ/UttuQPFJ7M1Rq64N1axTPYV12HexbBC2SJPVQ=; b=T+hbEweKWZKT+yyzPDlE7nZL1uJChbb+ZeP7/5YjXKEvCCYfJbqpVNKKTmrLttaf5j 5byHTBf13l0ub+VtF5zmOShMTvLn6Y7IojKkQm7t3nWKPnGQ2QkbcHDePRnflCoQoUZh M6Uw+JxbVxtHHnzYfu8cLgvSvFB/Xm3jPaZxD/Sg+SXBkSP7pvRiZkMd002R11JtAHlq p/8nWhqwU7XXpCHDjkfWzlR9tWhEExp87pgxim2WlLAZzuUPzbafosEHJyznJkZX79mG Uect+6qqdVLCDbeaAZnHYeViaJSwgEi2JOXtCTyTiqh2IoHMmSbrLWtRQBFDB6nQlpUx S6Mw== 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=Iu4YQ/UttuQPFJ7M1Rq64N1axTPYV12HexbBC2SJPVQ=; b=jEVnB1HdmkjMYKZ+9xBKUrKwBT92NRZcXjjFMUlOUArfLw0+BgGLa7b+HiVnSwA8RD quPlmCaTu2WDvjaTnSgsHqGPR6ib+EVnkPonefspTYB7zmG4Bjuo9wI+4ZkZ2wC3pWxQ sDmdMrZLtzcDfLktyM/i2N9tNdPLBn7SEHoaoUKogZj/3/vKuHd6ANGX0Sn4XcCx4fIs cQS6CZuKDkcpcpx7WEs3ENH9GAdpz/6V8MJvVeBlsvixU0RQgqHdoypWAqpsEWB3F1uI 8900t1P95dDGTNcuU5fTcVw1O6sRViIhe+95bHc/jT/xLSAld6d04XO3MSodV+V5ZiPn UbDw== X-Gm-Message-State: AOAM533KofLHrBKdH88mXEsmS16O0ll7uC38ir3Sa69TMnh68WW8SaWa 4RgyaYi5ff0/TD/+V+YIgIchQu2J2u2Q3M62 X-Received: by 2002:a1c:7e4e:: with SMTP id z75mr15778850wmc.168.1612192419484; Mon, 01 Feb 2021 07:13:39 -0800 (PST) Received: from dell.default ([91.110.221.188]) by smtp.gmail.com with ESMTPSA id 192sm23323381wme.27.2021.02.01.07.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 07:13:38 -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 15:12:07 +0000 Message-Id: <20210201151214.2193508-6-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201151214.2193508-1-lee.jones@linaro.org> References: <20210201151214.2193508-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 43a50072dd5b4..2bd4c38efa095 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -889,9 +889,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 */ @@ -926,11 +923,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 e531789aa440a..32a606b605cbb 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3234,7 +3234,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); @@ -3252,6 +3252,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) {