Skip to content

Commit edd3cb0

Browse files
Simon Schusterbrauner
authored andcommitted
copy_process: pass clone_flags as u64 across calltree
With the introduction of clone3 in commit 7f192e3 ("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. Signed-off-by: Simon Schuster <schuster.simon@siemens-energy.com> Link: https://lore.kernel.org/20250901-nios2-implement-clone3-v2-2-53fcf5577d57@siemens-energy.com Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 04ff482 commit edd3cb0

38 files changed

Lines changed: 59 additions & 59 deletions

block/blk-ioc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
286286
}
287287
EXPORT_SYMBOL_GPL(set_task_ioprio);
288288

289-
int __copy_io(unsigned long clone_flags, struct task_struct *tsk)
289+
int __copy_io(u64 clone_flags, struct task_struct *tsk)
290290
{
291291
struct io_context *ioc = current->io_context;
292292

fs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4200,7 +4200,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
42004200
}
42014201

42024202
__latent_entropy
4203-
struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
4203+
struct mnt_namespace *copy_mnt_ns(u64 flags, struct mnt_namespace *ns,
42044204
struct user_namespace *user_ns, struct fs_struct *new_fs)
42054205
{
42064206
struct mnt_namespace *new_ns;

include/linux/cgroup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ extern struct cgroup_namespace init_cgroup_ns;
796796

797797
void free_cgroup_ns(struct cgroup_namespace *ns);
798798

799-
struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
799+
struct cgroup_namespace *copy_cgroup_ns(u64 flags,
800800
struct user_namespace *user_ns,
801801
struct cgroup_namespace *old_ns);
802802

@@ -818,7 +818,7 @@ static inline void put_cgroup_ns(struct cgroup_namespace *ns)
818818

819819
static inline void free_cgroup_ns(struct cgroup_namespace *ns) { }
820820
static inline struct cgroup_namespace *
821-
copy_cgroup_ns(unsigned long flags, struct user_namespace *user_ns,
821+
copy_cgroup_ns(u64 flags, struct user_namespace *user_ns,
822822
struct cgroup_namespace *old_ns)
823823
{
824824
return old_ns;

include/linux/cred.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct cred {
148148

149149
extern void __put_cred(struct cred *);
150150
extern void exit_creds(struct task_struct *);
151-
extern int copy_creds(struct task_struct *, unsigned long);
151+
extern int copy_creds(struct task_struct *, u64);
152152
extern const struct cred *get_task_cred(struct task_struct *);
153153
extern struct cred *cred_alloc_blank(void);
154154
extern struct cred *prepare_creds(void);

include/linux/iocontext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ struct task_struct;
118118
#ifdef CONFIG_BLOCK
119119
void put_io_context(struct io_context *ioc);
120120
void exit_io_context(struct task_struct *task);
121-
int __copy_io(unsigned long clone_flags, struct task_struct *tsk);
122-
static inline int copy_io(unsigned long clone_flags, struct task_struct *tsk)
121+
int __copy_io(u64 clone_flags, struct task_struct *tsk);
122+
static inline int copy_io(u64 clone_flags, struct task_struct *tsk)
123123
{
124124
if (!current->io_context)
125125
return 0;
@@ -129,7 +129,7 @@ static inline int copy_io(unsigned long clone_flags, struct task_struct *tsk)
129129
struct io_context;
130130
static inline void put_io_context(struct io_context *ioc) { }
131131
static inline void exit_io_context(struct task_struct *task) { }
132-
static inline int copy_io(unsigned long clone_flags, struct task_struct *tsk)
132+
static inline int copy_io(u64 clone_flags, struct task_struct *tsk)
133133
{
134134
return 0;
135135
}

include/linux/ipc_namespace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
129129
#endif
130130

131131
#if defined(CONFIG_IPC_NS)
132-
extern struct ipc_namespace *copy_ipcs(unsigned long flags,
132+
extern struct ipc_namespace *copy_ipcs(u64 flags,
133133
struct user_namespace *user_ns, struct ipc_namespace *ns);
134134

135135
static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
@@ -151,7 +151,7 @@ static inline struct ipc_namespace *get_ipc_ns_not_zero(struct ipc_namespace *ns
151151

152152
extern void put_ipc_ns(struct ipc_namespace *ns);
153153
#else
154-
static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
154+
static inline struct ipc_namespace *copy_ipcs(u64 flags,
155155
struct user_namespace *user_ns, struct ipc_namespace *ns)
156156
{
157157
if (flags & CLONE_NEWIPC)

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ LSM_HOOK(int, 0, file_open, struct file *file)
211211
LSM_HOOK(int, 0, file_post_open, struct file *file, int mask)
212212
LSM_HOOK(int, 0, file_truncate, struct file *file)
213213
LSM_HOOK(int, 0, task_alloc, struct task_struct *task,
214-
unsigned long clone_flags)
214+
u64 clone_flags)
215215
LSM_HOOK(void, LSM_RET_VOID, task_free, struct task_struct *task)
216216
LSM_HOOK(int, 0, cred_alloc_blank, struct cred *cred, gfp_t gfp)
217217
LSM_HOOK(void, LSM_RET_VOID, cred_free, struct cred *cred)

include/linux/mnt_namespace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct fs_struct;
1111
struct user_namespace;
1212
struct ns_common;
1313

14-
extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *,
14+
extern struct mnt_namespace *copy_mnt_ns(u64, struct mnt_namespace *,
1515
struct user_namespace *, struct fs_struct *);
1616
extern void put_mnt_ns(struct mnt_namespace *ns);
1717
DEFINE_FREE(put_mnt_ns, struct mnt_namespace *, if (!IS_ERR_OR_NULL(_T)) put_mnt_ns(_T))

include/linux/nsproxy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static inline struct cred *nsset_cred(struct nsset *set)
103103
*
104104
*/
105105

106-
int copy_namespaces(unsigned long flags, struct task_struct *tsk);
106+
int copy_namespaces(u64 flags, struct task_struct *tsk);
107107
void exit_task_namespaces(struct task_struct *tsk);
108108
void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
109109
int exec_task_namespaces(void);

include/linux/pid_namespace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static inline int pidns_memfd_noexec_scope(struct pid_namespace *ns)
7878
}
7979
#endif
8080

81-
extern struct pid_namespace *copy_pid_ns(unsigned long flags,
81+
extern struct pid_namespace *copy_pid_ns(u64 flags,
8282
struct user_namespace *user_ns, struct pid_namespace *ns);
8383
extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
8484
extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
@@ -97,7 +97,7 @@ static inline int pidns_memfd_noexec_scope(struct pid_namespace *ns)
9797
return 0;
9898
}
9999

100-
static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
100+
static inline struct pid_namespace *copy_pid_ns(u64 flags,
101101
struct user_namespace *user_ns, struct pid_namespace *ns)
102102
{
103103
if (flags & CLONE_NEWPID)

0 commit comments

Comments
 (0)