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
1507 return NULL;1507 return NULL;
1508}1508}
1509 1509
1510static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)1510static 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
1548static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)1548static 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
1569static int copy_files(unsigned long clone_flags, struct task_struct *tsk,1569static 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
1648static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)1648static int copy_signal(u64 clone_flags, struct task_struct *tsk)
1649{1649{
1650 struct signal_struct *sig;1650 struct signal_struct *sig;
1651 1651

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