fork: make clone3(NULL, 0) equivalent to fork()

Allow userspace to pass clone3(NULL, 0) and have it act identical to
calling fork(). This allows userspace to implement fork() on top of
clone3(). While this is already possible by doing:

struct clone_args args = {
	.exit_signal = SIGCHLD,
};

clone3(args, sizeof(args);

This will cause the whole struct to be needlessly copied from userspace
to kernelspace. Having clone3(NULL, 0) act identical to fork() lets us
avoid this.

Since clone3() is not yet released there is practically little to no
chance of breaking existing users. But we should probably get this in
before we release a kernel with clone3().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Andy Lutomirsky <luto@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
1 file changed