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/nsproxy.c (1 of 38 files). Show all
Unified · Split
| @@ -64,7 +64,7 @@ static inline struct nsproxy *create_nsproxy(void) · 63 unmodified lines | ||
| 64 | 64 | * Return the newly created nsproxy. Do not attach this to the task, |
| 65 | 65 | * leave it to the caller to do proper locking and attach it to task. |
| 66 | 66 | */ |
| 67 | −static struct nsproxy *create_new_namespaces(unsigned long flags, | |
| 67 | +static struct nsproxy *create_new_namespaces(u64 flags, | |
| 68 | 68 | struct task_struct *tsk, struct user_namespace *user_ns, |
| 69 | 69 | struct fs_struct *new_fs) |
| 70 | 70 | { |
| @@ -144,7 +144,7 @@ out_ns: · 73 unmodified lines | ||
| 144 | 144 | * called from clone. This now handles copy for nsproxy and all |
| 145 | 145 | * namespaces therein. |
| 146 | 146 | */ |
| 147 | −int copy_namespaces(unsigned long flags, struct task_struct *tsk) | |
| 147 | +int copy_namespaces(u64 flags, struct task_struct *tsk) | |
| 148 | 148 | { |
| 149 | 149 | struct nsproxy *old_ns = tsk->nsproxy; |
| 150 | 150 | struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); |