Skip to content

Commit 6217387

Browse files
esyr-rhChristian Brauner
authored andcommitted
clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set
Passing CLONE_INTO_CGROUP with an under-sized structure (that doesn't properly contain cgroup field) seems like garbage input, especially considering the fact that fd 0 is a valid descriptor. Signed-off-by: Eugene Syromiatnikov <[email protected]> Acked-by: Christian Brauner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent e82a118 commit 6217387

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/fork.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2631,7 +2631,8 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
26312631
!valid_signal(args.exit_signal)))
26322632
return -EINVAL;
26332633

2634-
if ((args.flags & CLONE_INTO_CGROUP) && args.cgroup > INT_MAX)
2634+
if ((args.flags & CLONE_INTO_CGROUP) &&
2635+
(args.cgroup > INT_MAX || usize < CLONE_ARGS_SIZE_VER2))
26352636
return -EINVAL;
26362637

26372638
*kargs = (struct kernel_clone_args){

0 commit comments

Comments
 (0)