Skip to content

Commit e82a118

Browse files
esyr-rhChristian Brauner
authored andcommitted
clone3: fix cgroup argument sanity check
Checking that cgroup field value of struct clone_args is less than 0 is useless, as it is defined as unsigned 64-bit integer. Moreover, it doesn't catch the situations where its higher bits are lost during the assignment to the cgroup field of the cgroup field of the internal struct kernel_clone_args (where it is declared as signed 32-bit integer), so it is still possible to pass garbage there. A check against INT_MAX solves both these issues. Fixes: ef2c41c ("clone3: allow spawning processes into cgroups") 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 3075afd commit e82a118

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/fork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2631,7 +2631,7 @@ 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 < 0)
2634+
if ((args.flags & CLONE_INTO_CGROUP) && args.cgroup > INT_MAX)
26352635
return -EINVAL;
26362636

26372637
*kargs = (struct kernel_clone_args){

0 commit comments

Comments
 (0)