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/nsproxy.c (1 of 38 files). Show all

Unified · Split

kernel/nsproxy.c+2−2
@@ -64,7 +64,7 @@ static inline struct nsproxy *create_nsproxy(void) · 63 unmodified lines
6464 * Return the newly created nsproxy. Do not attach this to the task,
6565 * leave it to the caller to do proper locking and attach it to task.
6666 */
67−static struct nsproxy *create_new_namespaces(unsigned long flags,
67+static struct nsproxy *create_new_namespaces(u64 flags,
6868 struct task_struct *tsk, struct user_namespace *user_ns,
6969 struct fs_struct *new_fs)
7070 {
@@ -144,7 +144,7 @@ out_ns: · 73 unmodified lines
144144 * called from clone. This now handles copy for nsproxy and all
145145 * namespaces therein.
146146 */
147−int copy_namespaces(unsigned long flags, struct task_struct *tsk)
147+int copy_namespaces(u64 flags, struct task_struct *tsk)
148148 {
149149 struct nsproxy *old_ns = tsk->nsproxy;
150150 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);