From: Joe Perches <joe@perches.com>
To: Christian Brauner <christian.brauner@ubuntu.com>,
linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Eugene Syromiatnikov <esyr@redhat.com>,
Christian Kellner <christian@kellner.me>,
Aleksa Sarai <cyphar@cyphar.com>,
"Dmitry V. Levin" <ldv@altlinux.org>,
Arnd Bergmann <arnd@arndb.de>, Serge Hallyn <serge@hallyn.com>,
Tejun Heo <tj@kernel.org>, Oleg Nesterov <oleg@redhat.com>,
Jan Stancek <jstancek@redhat.com>,
Andreas Schwab <schwab@linux-m68k.org>,
Florian Weimer <fw@deneb.enyo.de>,
libc-alpha@sourceware.org
Subject: Re: [PATCH] clone: only use lower 32 flag bits
Date: Wed, 06 May 2020 12:06:10 -0700 [thread overview]
Message-ID: <aa9e029703e184a56bcab9f0992cfff316136d16.camel@perches.com> (raw)
In-Reply-To: <20200505174446.204918-1-christian.brauner@ubuntu.com>
On Tue, 2020-05-05 at 19:44 +0200, Christian Brauner wrote:
> Jan reported an issue where an interaction between sign-extending clone's
> flag argument on ppc64le and the new CLONE_INTO_CGROUP feature causes
> clone() to consistently fail with EBADF.
[]
> Let's fix this by always capping the upper 32 bits for the legacy clone()
> syscall. This ensures that we can't reach clone3() only features by
> accident via legacy clone as with the sign extension case and also that
> legacy clone() works exactly like before, i.e. ignoring any unknown flags.
> This solution risks no regressions and is also pretty clean.
>
> I've chosen u32 and not unsigned int to visually indicate that we're
> capping this to 32 bits.
Perhaps use the lower_32_bits macro?
> diff --git a/kernel/fork.c b/kernel/fork.c
[]
> @@ -2569,12 +2569,21 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
> unsigned long, tls)
> #endif
> {
> + /*
> + * On 64 bit unsigned long can be used by userspace to
> + * pass flag values only useable with clone3(). So cap
> + * the flag argument to the lower 32 bits. This is fine,
> + * since legacy clone() has traditionally ignored unknown
> + * flag values. So don't break userspace workloads that
> + * (on accident or on purpose) rely on this.
> + */
> + u32 flags = (u32)clone_flags;
> struct kernel_clone_args args = {
> - .flags = (clone_flags & ~CSIGNAL),
> + .flags = (flags & ~CSIGNAL),
so:
.flags = lower_32_bits(clone_flags) & ~CSIGNAL;
> .pidfd = parent_tidptr,
> .child_tid = child_tidptr,
> .parent_tid = parent_tidptr,
> - .exit_signal = (clone_flags & CSIGNAL),
> + .exit_signal = (flags & CSIGNAL),
.exit_signal = lower_32_bits(clone_flags) & CSIGNAL;
> .stack = newsp,
> .tls = tls,
> };
>
> base-commit: 0e698dfa282211e414076f9dc7e83c1c288314fd
next prev parent reply other threads:[~2020-05-06 19:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 17:44 Christian Brauner
2020-05-06 19:06 ` Joe Perches [this message]
2020-05-07 7:11 ` 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=aa9e029703e184a56bcab9f0992cfff316136d16.camel@perches.com \
--to=joe@perches.com \
--cc=arnd@arndb.de \
--cc=christian.brauner@ubuntu.com \
--cc=christian@kellner.me \
--cc=cyphar@cyphar.com \
--cc=esyr@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=jstancek@redhat.com \
--cc=ldv@altlinux.org \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=schwab@linux-m68k.org \
--cc=serge@hallyn.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
/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
all inboxes | Powered by JetHome®