From: Dmitry Safonov <0x7f454c46@gmail.com>
To: Adrian Reber <areber@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
Pavel Emelianov <xemul@virtuozzo.com>,
Jann Horn <jannh@google.com>, Oleg Nesterov <oleg@redhat.com>
Cc: linux-kernel@vger.kernel.org, Andrei Vagin <avagin@gmail.com>,
Mike Rapoport <rppt@linux.ibm.com>,
Radostin Stoyanov <rstoyanov1@gmail.com>
Subject: Re: [PATCH v2 1/2] fork: extend clone3() to support CLONE_SET_TID
Date: Wed, 31 Jul 2019 17:49:58 +0100 [thread overview]
Message-ID: <417a9682-c7fc-fec4-3510-81a8aa7cd0af@gmail.com> (raw)
In-Reply-To: <20190731161223.2928-1-areber@redhat.com>
Hi Adrian,
On 7/31/19 5:12 PM, Adrian Reber wrote:
[..]
> @@ -2530,14 +2530,12 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
> struct clone_args __user *uargs,
> size_t size)
> {
> + struct pid_namespace *pid_ns = task_active_pid_ns(current);
> struct clone_args args;
>
> if (unlikely(size > PAGE_SIZE))
> return -E2BIG;
>
> - if (unlikely(size < sizeof(struct clone_args)))
> - return -EINVAL;
> -
It might be better to validate it still somehow, but I don't insist.
[..]
> @@ -2578,11 +2580,16 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
>
> static bool clone3_args_valid(const struct kernel_clone_args *kargs)
> {
> - /*
> - * All lower bits of the flag word are taken.
> - * Verify that no other unknown flags are passed along.
> - */
> - if (kargs->flags & ~CLONE_LEGACY_FLAGS)
> + /* Verify that no other unknown flags are passed along. */
> + if (kargs->flags & ~(CLONE_LEGACY_FLAGS | CLONE_SET_TID))
> + return false;
> +
> + /* Fail if set_tid is set without CLONE_SET_TID */
> + if (kargs->set_tid && !(kargs->flags & CLONE_SET_TID))
> + return false;
> +
> + /* Also fail if set_tid is invalid */
> + if ((kargs->set_tid <= 0) && (kargs->flags & CLONE_SET_TID))
> return false;
Sorry for not mentioning it on v1, but I've noticed it only now:
you check kargs->set_tid even with the legacy-sized kernel_clone_args,
which is probably some random value on a task's stack?
[..]
Thanks much,
Dmitry
next prev parent reply other threads:[~2019-07-31 16:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 16:12 [PATCH v2 1/2] fork: extend clone3() to support CLONE_SET_TID Adrian Reber
2019-07-31 16:12 ` [PATCH v2 2/2] selftests: add test for clone3() with set_tid Adrian Reber
2019-07-31 16:49 ` Dmitry Safonov [this message]
2019-07-31 16:56 ` [PATCH v2 1/2] fork: extend clone3() to support CLONE_SET_TID Dmitry Safonov
2019-07-31 17:41 ` Oleg Nesterov
2019-08-02 7:25 ` Adrian Reber
2019-08-02 12:47 ` Oleg Nesterov
2019-08-02 13:02 ` Christian Brauner
2019-08-02 13:24 ` Oleg Nesterov
2019-08-02 13:46 ` Oleg Nesterov
2019-08-02 13:52 ` Christian Brauner
2019-08-02 16:50 ` Adrian Reber
2019-08-02 13:19 ` Christian Brauner
2019-08-02 13:30 ` Oleg Nesterov
2019-08-02 13:50 ` Christian Brauner
2019-08-02 15:10 ` Adrian Reber
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=417a9682-c7fc-fec4-3510-81a8aa7cd0af@gmail.com \
--to=0x7f454c46@gmail.com \
--cc=areber@redhat.com \
--cc=avagin@gmail.com \
--cc=christian@brauner.io \
--cc=ebiederm@xmission.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=rppt@linux.ibm.com \
--cc=rstoyanov1@gmail.com \
--cc=xemul@virtuozzo.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).