Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp746782ybl; Wed, 4 Dec 2019 10:10:55 -0800 (PST) X-Google-Smtp-Source: APXvYqz2Z0UiURvnQEyYdjQ/OLmS4IbBQAxaEnPYIUVFjk1SFYmWSatD/ZbZckozElUJFZXoLtNL X-Received: by 2002:aca:49d0:: with SMTP id w199mr3577950oia.14.1575483055416; Wed, 04 Dec 2019 10:10:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575483055; cv=none; d=google.com; s=arc-20160816; b=ykGH0233PteUfIeygDL97fT6rfZ+PbnTrrQ0lCtCmfi9eggMeSP1fw05MupFl9VCbh hVPlAV7ZtfDBrzlwy6GNY/+DkapnxLBfEz3skWDcdCoroSu+Dp1sMe/2P7l7VMkneQiW dv17MaPvGmeUFYz7RzTUTnYblEaDEwHSSH0R+Ixo0dFlRtTZXFR7u11b9Hqj0CpeiVqW g+UQFUCmwPbEu55nomQHvl/j206knXU5QTywGylVKST0Y8Qa9tc+4mqdbTIyyfpti6J6 /rQys5epaWmA2SGJ7vGnm4BbU5iLceGhNc1HyWv8KNsxvPeax3CDY2E6AmNmOAUKcAyJ 115Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yu+z3vflQ649wd7z/FLpIJbtdI9+rneUN+FIvGYIDdA=; b=CAfoEr+FtLj2V7r7SCmYj/LG3NLafqHz1k1Tzuyazix/PavVvVXmIhztNj2cDCKPAX gJhCB2SN2dT5W2D185I0ptUFYPdNeOpI397QlnxW1htmWgry4MZ8mRCBzxBUxUcFqwgV /2cITF+KYSgC+ua/117TRe9FflPzIhYen+ca8S+lJqmnILuDpJf8heMucoWQR9eOTbfv 1PSm6TGVW9SLHERPN9LQ95JhFGRoYLnMFMQ/tJZhB9AjYqPMoNfbKN4xnWaEOSPjd2DL 7j8270oF69dx4vpsJVPi/bMS8fhxMmFjanX+lohy6Wnedk7uAOiO4SY1pqiiLczdaMdd 893Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="i3Rvk/5k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si3647895otn.53.2019.12.04.10.10.43; Wed, 04 Dec 2019 10:10:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="i3Rvk/5k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731108AbfLDSJj (ORCPT + 99 others); Wed, 4 Dec 2019 13:09:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:35546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731090AbfLDSJg (ORCPT ); Wed, 4 Dec 2019 13:09:36 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF6CA20833; Wed, 4 Dec 2019 18:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482975; bh=0tJvrCfW3bpP7zzlMrl5a0A/G33lDyFmyoXU2iUME0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i3Rvk/5kvUNmtGigWTYeCqnFBnLCRNrXujpMLgEBZoYU/8x/MQfUfHoVMgSFMSggP aEIUFei/1kmbP3NZHjYjViRvx5xRYt7MVT6UK7xt8NrGfuRTETFWQtKxFIIHO6XzQ0 AkBCGxpRja9ArxyW4CjCF3SMNASEOxTejHqg9bek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "Peter Zijlstra (Intel)" Subject: [PATCH 4.14 189/209] exit/exec: Seperate mm_release() Date: Wed, 4 Dec 2019 18:56:41 +0100 Message-Id: <20191204175336.499583786@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 4610ba7ad877fafc0a25a30c6c82015304120426 upstream. mm_release() contains the futex exit handling. mm_release() is called from do_exit()->exit_mm() and from exec()->exec_mm(). In the exit_mm() case PF_EXITING and the futex state is updated. In the exec_mm() case these states are not touched. As the futex exit code needs further protections against exit races, this needs to be split into two functions. 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.240518241@linutronix.de Signed-off-by: Greg Kroah-Hartman --- fs/exec.c | 2 +- include/linux/sched/mm.h | 6 ++++-- kernel/exit.c | 2 +- kernel/fork.c | 12 +++++++++++- 4 files changed, 17 insertions(+), 5 deletions(-) --- a/fs/exec.c +++ b/fs/exec.c @@ -1007,7 +1007,7 @@ static int exec_mmap(struct mm_struct *m /* Notify parent that we're no longer interested in the old VM */ tsk = current; old_mm = current->mm; - mm_release(tsk, old_mm); + exec_mm_release(tsk, old_mm); if (old_mm) { sync_mm_rss(old_mm); --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -125,8 +125,10 @@ extern struct mm_struct *get_task_mm(str * succeeds. */ extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode); -/* Remove the current tasks stale references to the old mm_struct */ -extern void mm_release(struct task_struct *, struct mm_struct *); +/* Remove the current tasks stale references to the old mm_struct on exit() */ +extern void exit_mm_release(struct task_struct *, struct mm_struct *); +/* Remove the current tasks stale references to the old mm_struct on exec() */ +extern void exec_mm_release(struct task_struct *, struct mm_struct *); #ifdef CONFIG_MEMCG extern void mm_update_next_owner(struct mm_struct *mm); --- a/kernel/exit.c +++ b/kernel/exit.c @@ -497,7 +497,7 @@ static void exit_mm(void) struct mm_struct *mm = current->mm; struct core_state *core_state; - mm_release(current, mm); + exit_mm_release(current, mm); if (!mm) return; sync_mm_rss(mm); --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1132,7 +1132,7 @@ static int wait_for_vfork_done(struct ta * restoring the old one. . . * Eric Biederman 10 January 1998 */ -void mm_release(struct task_struct *tsk, struct mm_struct *mm) +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); @@ -1169,6 +1169,16 @@ void mm_release(struct task_struct *tsk, complete_vfork_done(tsk); } +void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm) +{ + mm_release(tsk, mm); +} + +void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm) +{ + mm_release(tsk, mm); +} + /* * Allocate a new mm structure and copy contents from the * mm structure of the passed in task structure.