Skip to content

Commit 774acb2

Browse files
committed
Merge tag 'for-linus-2020-04-18' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux
Pull thread fixes from Christian Brauner: "A few fixes and minor improvements: - Correctly validate the cgroup file descriptor when clone3() is used with CLONE_INTO_CGROUP. - Check that a new enough version of struct clone_args is passed which supports the cgroup file descriptor argument when CLONE_INTO_CGROUP is set in the flags argument. - Catch nonsensical struct clone_args layouts at build time. - Catch extensions of struct clone_args without updating the uapi visible size definitions at build time. - Check whether the signal is valid early in kill_pid_usb_asyncio() before doing further work. - Replace open-coded rcu_read_lock()+kill_pid_info()+rcu_read_unlock() sequence in kill_something_info() with kill_proc_info() which is a dedicated helper to do just that" * tag 'for-linus-2020-04-18' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: clone3: add build-time CLONE_ARGS_SIZE_VER* validity checks clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set clone3: fix cgroup argument sanity check signal: use kill_proc_info instead of kill_pid_info in kill_something_info signal: check sig before setting info in kill_pid_usb_asyncio
2 parents b484f3c + a966dcf commit 774acb2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

kernel/fork.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,14 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
26052605
struct clone_args args;
26062606
pid_t *kset_tid = kargs->set_tid;
26072607

2608+
BUILD_BUG_ON(offsetofend(struct clone_args, tls) !=
2609+
CLONE_ARGS_SIZE_VER0);
2610+
BUILD_BUG_ON(offsetofend(struct clone_args, set_tid_size) !=
2611+
CLONE_ARGS_SIZE_VER1);
2612+
BUILD_BUG_ON(offsetofend(struct clone_args, cgroup) !=
2613+
CLONE_ARGS_SIZE_VER2);
2614+
BUILD_BUG_ON(sizeof(struct clone_args) != CLONE_ARGS_SIZE_VER2);
2615+
26082616
if (unlikely(usize > PAGE_SIZE))
26092617
return -E2BIG;
26102618
if (unlikely(usize < CLONE_ARGS_SIZE_VER0))
@@ -2631,7 +2639,8 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
26312639
!valid_signal(args.exit_signal)))
26322640
return -EINVAL;
26332641

2634-
if ((args.flags & CLONE_INTO_CGROUP) && args.cgroup < 0)
2642+
if ((args.flags & CLONE_INTO_CGROUP) &&
2643+
(args.cgroup > INT_MAX || usize < CLONE_ARGS_SIZE_VER2))
26352644
return -EINVAL;
26362645

26372646
*kargs = (struct kernel_clone_args){

kernel/signal.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,15 +1510,15 @@ int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr,
15101510
unsigned long flags;
15111511
int ret = -EINVAL;
15121512

1513+
if (!valid_signal(sig))
1514+
return ret;
1515+
15131516
clear_siginfo(&info);
15141517
info.si_signo = sig;
15151518
info.si_errno = errno;
15161519
info.si_code = SI_ASYNCIO;
15171520
*((sigval_t *)&info.si_pid) = addr;
15181521

1519-
if (!valid_signal(sig))
1520-
return ret;
1521-
15221522
rcu_read_lock();
15231523
p = pid_task(pid, PIDTYPE_PID);
15241524
if (!p) {
@@ -1557,12 +1557,8 @@ static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid)
15571557
{
15581558
int ret;
15591559

1560-
if (pid > 0) {
1561-
rcu_read_lock();
1562-
ret = kill_pid_info(sig, info, find_vpid(pid));
1563-
rcu_read_unlock();
1564-
return ret;
1565-
}
1560+
if (pid > 0)
1561+
return kill_proc_info(sig, info, pid);
15661562

15671563
/* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */
15681564
if (pid == INT_MIN)

0 commit comments

Comments
 (0)