Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp399683imm; Wed, 29 Aug 2018 02:56:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZDMQXOOtE31NVyWkADO5cHZ9LykbHqYO1zuz/vYwjY4qJkUZTuN6IuT8qRloDO7iVY3jpR X-Received: by 2002:a63:d857:: with SMTP id k23-v6mr5068310pgj.106.1535536570412; Wed, 29 Aug 2018 02:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535536570; cv=none; d=google.com; s=arc-20160816; b=bZLpX3S/R58VMT/mIu+Ov6U923Qnpg2k/rAWHCOTMZeLjgCOcUyCT2ASqxD/KoPv+d Z5zB9mc8IdjsV+/64UtKj5iRU51jvXXrXJOSHrVlIv3vBoJv/mkWTYuSDQWctZXT8/pP aK8XlhFKMUtP4OkljTcrRfD+EcWGOcNBaKiNbGEXamL/lvZBN1WwpcAwe5Dkx5gpAyyc cGwrC+XDmGtxynCg+moRjwyFT66cBqy0z+wkkXQBqUpNrB/Jth4ivNGHNqQX9/G7S05+ 27ML1qJT7OxRc0FIrApXll7IjVNL9BKqBWSN45kvGj3AcZM9m6H2bKeL/QEY7Rg+yC/T 3e8Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=fCFQoJbKQwOWR5kP2z4U61RdwYdHD1Swdpj/Om12Eak=; b=J/fhQwouqXDvwVj0do8/iKfPufmmpof8Y5frG/PawoIU7M5BNKbCA5Xo2tLTT88k6i 5qwn83w+C6T0T3H1axkIk90JAtVeLgQ9UcJxRq6WbKHRLHeLbde8OofYFMjao+ehxux3 LZ3zWy7qqwLr2Uhv9hgnHV4KdOi2SUDrxgRPWTjzgipZA8XKC1jsHMyoF7XweBHTZj62 /dPBczZJwLgD9DNlSp6aq/FuZlH/jRW9zyfRt16pDsSHUegjJNEaFWr8/bEY0bOEqHR3 kV/Kxn6nViB9vpTupY23jlRjIG4U2RifW4QRztm4ga0/lxLPApmknQcRuhv/9o2T7ORx JcAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="IQFeh/4f"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22-v6si3456841pgj.436.2018.08.29.02.55.51; Wed, 29 Aug 2018 02:56:10 -0700 (PDT) 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="IQFeh/4f"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727990AbeH2Nuj (ORCPT + 99 others); Wed, 29 Aug 2018 09:50:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbeH2Nui (ORCPT ); Wed, 29 Aug 2018 09:50:38 -0400 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 6869020645; Wed, 29 Aug 2018 09:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1535536472; bh=O7X/ndkF7y7dDouf8PlkYnHhVhmND3ppmDmSQXNvF+M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IQFeh/4fYZpCJAkTTRdNxJLn7NSow52BRO08OypQ5iZvCLVKZ/pPsO/C7kPMPHSXq mGmW0y7eoubK62UJ1xOMG/w4vq76yQUy2DfW9n7+kbpIxW6lDO3sEXQcy/yvNw/PAV Zytk4pvZFaTgSKTI1iL4EfKxsfbSoWS4/k2K/KQQ= Date: Wed, 29 Aug 2018 18:54:28 +0900 From: Masami Hiramatsu To: Nadav Amit Cc: Thomas Gleixner , , Ingo Molnar , , Arnd Bergmann , , Andy Lutomirski , Masami Hiramatsu , Kees Cook , Peter Zijlstra Subject: Re: [RFC PATCH 3/6] fork: provide a function for copying init_mm Message-Id: <20180829185428.e59fe325efcd4eb675e3eee3@kernel.org> In-Reply-To: <20180829081147.184610-4-namit@vmware.com> References: <20180829081147.184610-1-namit@vmware.com> <20180829081147.184610-4-namit@vmware.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Aug 2018 01:11:44 -0700 Nadav Amit wrote: > Provide a function for copying init_mm. This function will be later used > for setting a temporary mm. This looks good to me :) Reviewed-by: Masami Hiramatsu Thanks! > > Cc: Andy Lutomirski > Cc: Masami Hiramatsu > Cc: Kees Cook > Cc: Peter Zijlstra > Signed-off-by: Nadav Amit > --- > include/linux/sched/task.h | 1 + > kernel/fork.c | 24 ++++++++++++++++++------ > 2 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h > index 108ede99e533..ac0a675678f5 100644 > --- a/include/linux/sched/task.h > +++ b/include/linux/sched/task.h > @@ -74,6 +74,7 @@ extern void exit_itimers(struct signal_struct *); > extern long _do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *, unsigned long); > extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *); > struct task_struct *fork_idle(int); > +struct mm_struct *copy_init_mm(void); > extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); > extern long kernel_wait4(pid_t, int __user *, int, struct rusage *); > > diff --git a/kernel/fork.c b/kernel/fork.c > index d896e9ca38b0..a1c637b903c1 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1254,13 +1254,20 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) > complete_vfork_done(tsk); > } > > -/* > - * Allocate a new mm structure and copy contents from the > - * mm structure of the passed in task structure. > +/** > + * dup_mm() - duplicates an existing mm structure > + * @tsk: the task_struct with which the new mm will be associated. > + * @oldmm: the mm to duplicate. > + * > + * Allocates a new mm structure and copy contents from the provided > + * @oldmm structure. > + * > + * Return: the duplicated mm or NULL on failure. > */ > -static struct mm_struct *dup_mm(struct task_struct *tsk) > +static struct mm_struct *dup_mm(struct task_struct *tsk, > + struct mm_struct *oldmm) > { > - struct mm_struct *mm, *oldmm = current->mm; > + struct mm_struct *mm; > int err; > > mm = allocate_mm(); > @@ -1327,7 +1334,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) > } > > retval = -ENOMEM; > - mm = dup_mm(tsk); > + mm = dup_mm(tsk, current->mm); > if (!mm) > goto fail_nomem; > > @@ -2127,6 +2134,11 @@ struct task_struct *fork_idle(int cpu) > return task; > } > > +struct mm_struct *copy_init_mm(void) > +{ > + return dup_mm(NULL, &init_mm); > +} > + > /* > * Ok, this is the main fork-routine. > * > -- > 2.17.1 > -- Masami Hiramatsu