LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christian Brauner <christian@brauner.io>
To: David Howells <dhowells@redhat.com>
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, jannh@google.com,
keescook@chromium.org, fweimer@redhat.com, oleg@redhat.com,
arnd@arndb.de, Pavel Emelyanov <xemul@virtuozzo.com>,
Andrew Morton <akpm@linux-foundation.org>,
Adrian Reber <adrian@lisas.de>, Andrei Vagin <avagin@gmail.com>,
linux-api@vger.kernel.org
Subject: Re: [PATCH v2 1/2] fork: add clone3
Date: Tue, 4 Jun 2019 11:56:33 +0200 [thread overview]
Message-ID: <20190604095632.gsapgrmvup3mabga@brauner.io> (raw)
In-Reply-To: <20190604094317.4wfelmbw4lgxzide@brauner.io>
On Tue, Jun 04, 2019 at 11:43:17AM +0200, Christian Brauner wrote:
> On Tue, Jun 04, 2019 at 10:28:12AM +0100, David Howells wrote:
> > Christian Brauner <christian@brauner.io> wrote:
> >
> > > +#include <linux/compiler_types.h>
> >
> > I suspect you don't want to include that directly.
> >
> > Also, to avoid bloating linux/sched/task.h yet further, maybe put this in
> > linux/sched/clone.h?
>
> Yeah, not the worst idea.
> Though I'd leave the flags where they are and just add struct
> kernel_clone_args in there. But I assume that's what you meant anyway.
Actually, I would like to defer this to the cleanup patch too.
This way the patch stays small and clean and task.h is currently the
right place to put it.
>
> >
> > > -extern long _do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *, unsigned long);
> > > +extern long _do_fork(struct kernel_clone_args *kargs);
> > > extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
> >
> > Maybe these could move into linux/sched/clone.h too.
>
> Meh, that could be a separate cleanup patch after clone3() has been
> merged.
>
> >
> > > +#define CLONE_MAX ~0U
> >
> > Can you add a comment summarising the meaning?
>
> Yes, can do.
>
> >
> > > + u64 clone_flags = args->flags;
> > > + int __user *child_tidptr = args->child_tid;
> > > + unsigned long tls = args->tls;
> > > + unsigned long stack_start = args->stack;
> > > + unsigned long stack_size = args->stack_size;
> >
> > Some of these are only used once, so it's probably not worth sticking them in
> > local variables.
>
> [1]:
> Ok, will double check.
> This was just to minimize copy-paste erros for variables which were used
> multiple times.
>
> >
> > > - if (clone_flags &
> > > - (CLONE_DETACHED | CLONE_PARENT_SETTID | CLONE_THREAD))
> > > - return ERR_PTR(-EINVAL);
> >
> > Did this error check get lost? I can see part of it further on, but the check
> > on CLONE_PARENT_SETTID is absent.
>
> No, it's only relevant for legacy clone() since it uses the
> parent_tidptr argument to return the pidfd. clone3() has a dedicated
> return argument for that in clone_args.
> The check for legacy clone() is now done in legacy clone() directly.
> copy_process() should only do generic checks for all version of
> clone(),fork(),vfork(), etc.
>
> >
> > > + int __user *parent_tidptr = args->parent_tid;
> >
> > There's only one usage remaining after this patch, so a local var doesn't gain
> > a lot.
>
> Yes, that leads back to [1].
>
> >
> > > pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
> > > {
> > > - return _do_fork(flags|CLONE_VM|CLONE_UNTRACED, (unsigned long)fn,
> > > - (unsigned long)arg, NULL, NULL, 0);
> > > + struct kernel_clone_args args = {
> > > + .flags = ((flags | CLONE_VM | CLONE_UNTRACED) & ~CSIGNAL),
> > > + .exit_signal = (flags & CSIGNAL),
> >
> > Kernel threads can have exit signals?
>
> Yes,
>
> kernel/kthread.c: pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
> kernel/umh.c: pid = kernel_thread(call_usermodehelper_exec_async, sub_info, SIGCHLD);
>
> And even if they couldn't have. This is just to make sure that if they
> ever would we'd be prepared.
>
> >
> > > +static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
> > > + struct clone_args __user *uargs,
> > > + size_t size)
> >
> > I would make this "noinline". If it gets inlined, local variable "args" may
> > still be on the stack when _do_fork() gets called.
>
> Hm, can do.
>
> Thanks!
> Christian
next prev parent reply other threads:[~2019-06-04 9:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 14:43 Christian Brauner
2019-06-03 14:43 ` [PATCH v2 2/2] arch: wire-up clone3() syscall on x86 Christian Brauner
2019-06-04 9:28 ` [PATCH v2 1/2] fork: add clone3 David Howells
2019-06-04 9:43 ` Christian Brauner
2019-06-04 9:56 ` Christian Brauner [this message]
2019-06-04 10:42 ` David Laight
2019-06-04 10:36 ` Arnd Bergmann
2019-06-04 10:49 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604095632.gsapgrmvup3mabga@brauner.io \
--to=christian@brauner.io \
--cc=adrian@lisas.de \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=avagin@gmail.com \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@virtuozzo.com \
--subject='Re: [PATCH v2 1/2] fork: add clone3' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).