mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
for-linus-20190715
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCXSxgkQAKCRCRxhvAZXjc opJ3AP9TWIWhEC0dzbNmzh0STj/Vyl5KYEpdMbi7HNeAmIEAfQD6A3HI4bVJbN08 jH44U7DLzHJyHefKlB8jHEKEVYJWqgo= =74Bg -----END PGP SIGNATURE----- Merge tag 'for-linus-20190715' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux Pull pidfd and clone3 fixes from Christian Brauner: "This contains a bugfix for CLONE_PIDFD when used with the legacy clone syscall, two fixes to ensure that syscall numbering and clone3 entrypoint implementations will stay consistent, and an update for the maintainers file: - The addition of clone3 broke CLONE_PIDFD for legacy clone on all architectures that use do_fork() directly instead of calling the clone syscall itself. (Fwiw, cleaning do_fork() up is on my todo.) The reason this happened was that during conversion of _do_fork() to use struct kernel_clone_args we missed that do_fork() is called directly by various architectures. This is fixed by making sure that the pidfd argument in struct kernel_clone_args is correctly initialized with the parent_tidptr argument passed down from do_fork(). Additionally, do_fork() missed a check to make CLONE_PIDFD and CLONE_PARENT_SETTID mutually exclusive just a clone() does. This is now fixed too. - When clone3() was introduced we skipped architectures that require special handling for fork-like syscalls. Their syscall tables did not contain any mention of clone3(). To make sure that Arnd's work to make syscall numbers on all architectures identical (minus alpha) was not for naught we are placing a comment in all syscall tables that do not yet implement clone3(). The comment makes it clear that 435 is reserved for clone3 and should not be used. - Also, this contains a patch to make the clone3() syscall definition in asm-generic/unist.h conditional on __ARCH_WANT_SYS_CLONE3. This lets us catch new architectures that implicitly make use of clone3 without setting __ARCH_WANT_SYS_CLONE3 which is a good indicator that they did not check whether it needs special treatment or not. - Finally, this contains a patch to add me as maintainer for pidfd stuff so people can start blaming me (more)" * tag 'for-linus-20190715' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: MAINTAINERS: add new entry for pidfd api unistd: protect clone3 via __ARCH_WANT_SYS_CLONE3 arch: mark syscall number 435 reserved for clone3 clone: fix CLONE_PIDFD support
This commit is contained in:
commit
3c69914b4c
11
MAINTAINERS
11
MAINTAINERS
@ -12611,6 +12611,17 @@ F: arch/arm/boot/dts/picoxcell*
|
||||
F: arch/arm/mach-picoxcell/
|
||||
F: drivers/crypto/picoxcell*
|
||||
|
||||
PIDFD API
|
||||
M: Christian Brauner <christian@brauner.io>
|
||||
L: linux-kernel@vger.kernel.org
|
||||
S: Maintained
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
|
||||
F: samples/pidfd/
|
||||
F: tools/testing/selftests/pidfd/
|
||||
K: (?i)pidfd
|
||||
K: (?i)clone3
|
||||
K: \b(clone_args|kernel_clone_args)\b
|
||||
|
||||
PIN CONTROL SUBSYSTEM
|
||||
M: Linus Walleij <linus.walleij@linaro.org>
|
||||
L: linux-gpio@vger.kernel.org
|
||||
|
@ -474,3 +474,4 @@
|
||||
542 common fsmount sys_fsmount
|
||||
543 common fspick sys_fspick
|
||||
544 common pidfd_open sys_pidfd_open
|
||||
# 545 reserved for clone3
|
||||
|
@ -355,3 +355,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -434,3 +434,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -373,3 +373,4 @@
|
||||
432 n32 fsmount sys_fsmount
|
||||
433 n32 fspick sys_fspick
|
||||
434 n32 pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -349,3 +349,4 @@
|
||||
432 n64 fsmount sys_fsmount
|
||||
433 n64 fspick sys_fspick
|
||||
434 n64 pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -422,3 +422,4 @@
|
||||
432 o32 fsmount sys_fsmount
|
||||
433 o32 fspick sys_fspick
|
||||
434 o32 pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -431,3 +431,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -516,3 +516,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -437,3 +437,4 @@
|
||||
432 common fsmount sys_fsmount sys_fsmount
|
||||
433 common fspick sys_fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -437,3 +437,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -480,3 +480,4 @@
|
||||
432 common fsmount sys_fsmount
|
||||
433 common fspick sys_fspick
|
||||
434 common pidfd_open sys_pidfd_open
|
||||
# 435 reserved for clone3
|
||||
|
@ -239,6 +239,7 @@ COMPAT_SYSCALL_DEFINE5(x86_clone, unsigned long, clone_flags,
|
||||
{
|
||||
struct kernel_clone_args args = {
|
||||
.flags = (clone_flags & ~CSIGNAL),
|
||||
.pidfd = parent_tidptr,
|
||||
.child_tid = child_tidptr,
|
||||
.parent_tid = parent_tidptr,
|
||||
.exit_signal = (clone_flags & CSIGNAL),
|
||||
@ -246,5 +247,8 @@ COMPAT_SYSCALL_DEFINE5(x86_clone, unsigned long, clone_flags,
|
||||
.tls = tls_val,
|
||||
};
|
||||
|
||||
if (!legacy_clone_args_valid(&args))
|
||||
return -EINVAL;
|
||||
|
||||
return _do_fork(&args);
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ extern void exit_files(struct task_struct *);
|
||||
extern void exit_itimers(struct signal_struct *);
|
||||
|
||||
extern long _do_fork(struct kernel_clone_args *kargs);
|
||||
extern bool legacy_clone_args_valid(const struct kernel_clone_args *kargs);
|
||||
extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
|
||||
struct task_struct *fork_idle(int);
|
||||
struct mm_struct *copy_init_mm(void);
|
||||
|
@ -846,8 +846,10 @@ __SYSCALL(__NR_fsmount, sys_fsmount)
|
||||
__SYSCALL(__NR_fspick, sys_fspick)
|
||||
#define __NR_pidfd_open 434
|
||||
__SYSCALL(__NR_pidfd_open, sys_pidfd_open)
|
||||
#ifdef __ARCH_WANT_SYS_CLONE3
|
||||
#define __NR_clone3 435
|
||||
__SYSCALL(__NR_clone3, sys_clone3)
|
||||
#endif
|
||||
|
||||
#undef __NR_syscalls
|
||||
#define __NR_syscalls 436
|
||||
|
@ -2405,6 +2405,16 @@ long _do_fork(struct kernel_clone_args *args)
|
||||
return nr;
|
||||
}
|
||||
|
||||
bool legacy_clone_args_valid(const struct kernel_clone_args *kargs)
|
||||
{
|
||||
/* clone(CLONE_PIDFD) uses parent_tidptr to return a pidfd */
|
||||
if ((kargs->flags & CLONE_PIDFD) &&
|
||||
(kargs->flags & CLONE_PARENT_SETTID))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_HAVE_COPY_THREAD_TLS
|
||||
/* For compatibility with architectures that call do_fork directly rather than
|
||||
* using the syscall entry points below. */
|
||||
@ -2416,6 +2426,7 @@ long do_fork(unsigned long clone_flags,
|
||||
{
|
||||
struct kernel_clone_args args = {
|
||||
.flags = (clone_flags & ~CSIGNAL),
|
||||
.pidfd = parent_tidptr,
|
||||
.child_tid = child_tidptr,
|
||||
.parent_tid = parent_tidptr,
|
||||
.exit_signal = (clone_flags & CSIGNAL),
|
||||
@ -2423,6 +2434,9 @@ long do_fork(unsigned long clone_flags,
|
||||
.stack_size = stack_size,
|
||||
};
|
||||
|
||||
if (!legacy_clone_args_valid(&args))
|
||||
return -EINVAL;
|
||||
|
||||
return _do_fork(&args);
|
||||
}
|
||||
#endif
|
||||
@ -2504,8 +2518,7 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
|
||||
.tls = tls,
|
||||
};
|
||||
|
||||
/* clone(CLONE_PIDFD) uses parent_tidptr to return a pidfd */
|
||||
if ((clone_flags & CLONE_PIDFD) && (clone_flags & CLONE_PARENT_SETTID))
|
||||
if (!legacy_clone_args_valid(&args))
|
||||
return -EINVAL;
|
||||
|
||||
return _do_fork(&args);
|
||||
|
Loading…
Reference in New Issue
Block a user