History

copy_process: pass clone_flags as u64 across calltree

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.

Simon Schuster committed 1 year ago

Commit edd3cb01 parent 04ff48238 files · +59 −59Browse files

Showing the changes to kernel/fork.c (1 of 38 files). Show all

Unified · Split

kernel/fork.c+4−4
@@ -1507,7 +1507,7 @@ fail_nomem: · 1506 unmodified lines
15071507 return NULL;
15081508 }
15091509
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)
15111511 {
15121512 struct mm_struct *mm, *oldmm;
15131513
@@ -1545,7 +1545,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) · 31 unmodified lines
15451545 return 0;
15461546 }
15471547
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)
15491549 {
15501550 struct fs_struct *fs = current->fs;
15511551 if (clone_flags & CLONE_FS) {
@@ -1566,7 +1566,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) · 14 unmodified lines
15661566 return 0;
15671567 }
15681568
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,
15701570 int no_files)
15711571 {
15721572 struct files_struct *oldf, *newf;
@@ -1645,7 +1645,7 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) · 72 unmodified lines
16451645 posix_cputimers_group_init(pct, cpu_limit);
16461646 }
16471647
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)
16491649 {
16501650 struct signal_struct *sig;
16511651

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t