LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christian Brauner <christian@brauner.io>
Cc: dhowells@redhat.com, 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, 04 Jun 2019 10:28:12 +0100 [thread overview]
Message-ID: <4020.1559640492@warthog.procyon.org.uk> (raw)
In-Reply-To: <20190603144331.16760-1-christian@brauner.io>
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?
> -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.
> +#define CLONE_MAX ~0U
Can you add a comment summarising the meaning?
> + 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.
> - 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.
> + 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.
> 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?
> +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.
David
next prev parent reply other threads:[~2019-06-04 9:28 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 ` David Howells [this message]
2019-06-04 9:43 ` [PATCH v2 1/2] fork: add clone3 Christian Brauner
2019-06-04 9:56 ` Christian Brauner
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=4020.1559640492@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=adrian@lisas.de \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=avagin@gmail.com \
--cc=christian@brauner.io \
--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).