With the introduction of clone3 in commit 7f192e3cd316 ("fork: add clone3") the effective bit width of clone_flags on all architectures was increased from 32-bit to 64-bit, with a new type of u64 for the flags. However, for most consumers of clone_flags the interface was not changed from the previous type of unsigned long. While this works fine as long as none of the new 64-bit flag bits (CLONE_CLEAR_SIGHAND and CLONE_INTO_CGROUP) are evaluated, this is still undesirable in terms of the principle of least surprise. Thus, this commit fixes all relevant interfaces of callees to sys_clone3/copy_process (excluding the architecture-specific copy_thread) to consistently pass clone_flags as u64, so that no truncation to 32-bit integers occurs on 32-bit architectures.
Showing the changes to kernel/fork.c (1 of 38 files). Show all
Unified · Split
| @@ -1507,7 +1507,7 @@ fail_nomem: · 1506 unmodified lines | |||
| 1507 | return NULL; | 1507 | return NULL; |
| 1508 | } | 1508 | } |
| 1509 | 1509 | ||
| 1510 | static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) | 1510 | static int copy_mm(u64 clone_flags, struct task_struct *tsk) |
| 1511 | { | 1511 | { |
| 1512 | struct mm_struct *mm, *oldmm; | 1512 | struct mm_struct *mm, *oldmm; |
| 1513 | 1513 | ||
| @@ -1545,7 +1545,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) · 31 unmodified lines | |||
| 1545 | return 0; | 1545 | return 0; |
| 1546 | } | 1546 | } |
| 1547 | 1547 | ||
| 1548 | static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) | 1548 | static int copy_fs(u64 clone_flags, struct task_struct *tsk) |
| 1549 | { | 1549 | { |
| 1550 | struct fs_struct *fs = current->fs; | 1550 | struct fs_struct *fs = current->fs; |
| 1551 | if (clone_flags & CLONE_FS) { | 1551 | if (clone_flags & CLONE_FS) { |
| @@ -1566,7 +1566,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) · 14 unmodified lines | |||
| 1566 | return 0; | 1566 | return 0; |
| 1567 | } | 1567 | } |
| 1568 | 1568 | ||
| 1569 | static int copy_files(unsigned long clone_flags, struct task_struct *tsk, | 1569 | static int copy_files(u64 clone_flags, struct task_struct *tsk, |
| 1570 | int no_files) | 1570 | int no_files) |
| 1571 | { | 1571 | { |
| 1572 | struct files_struct *oldf, *newf; | 1572 | struct files_struct *oldf, *newf; |
| @@ -1645,7 +1645,7 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) · 72 unmodified lines | |||
| 1645 | posix_cputimers_group_init(pct, cpu_limit); | 1645 | posix_cputimers_group_init(pct, cpu_limit); |
| 1646 | } | 1646 | } |
| 1647 | 1647 | ||
| 1648 | static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | 1648 | static int copy_signal(u64 clone_flags, struct task_struct *tsk) |
| 1649 | { | 1649 | { |
| 1650 | struct signal_struct *sig; | 1650 | struct signal_struct *sig; |
| 1651 | 1651 | ||