mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-18 07:18:05 -05:00
copy_process: pass clone_flags as u64 across calltree
With the introduction of clone3 in commit 7f192e3cd3 ("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>
This commit is contained in:
committed by
Christian Brauner
parent
04ff48239f
commit
edd3cb05c0
@@ -47,7 +47,7 @@ void free_cgroup_ns(struct cgroup_namespace *ns)
|
||||
}
|
||||
EXPORT_SYMBOL(free_cgroup_ns);
|
||||
|
||||
struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
|
||||
struct cgroup_namespace *copy_cgroup_ns(u64 flags,
|
||||
struct user_namespace *user_ns,
|
||||
struct cgroup_namespace *old_ns)
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ struct cred *prepare_exec_creds(void)
|
||||
* The new process gets the current process's subjective credentials as its
|
||||
* objective and subjective credentials
|
||||
*/
|
||||
int copy_creds(struct task_struct *p, unsigned long clone_flags)
|
||||
int copy_creds(struct task_struct *p, u64 clone_flags)
|
||||
{
|
||||
struct cred *new;
|
||||
int ret;
|
||||
|
||||
@@ -2160,7 +2160,7 @@ static void dup_xol_work(struct callback_head *work)
|
||||
/*
|
||||
* Called in context of a new clone/fork from copy_process.
|
||||
*/
|
||||
void uprobe_copy_process(struct task_struct *t, unsigned long flags)
|
||||
void uprobe_copy_process(struct task_struct *t, u64 flags)
|
||||
{
|
||||
struct uprobe_task *utask = current->utask;
|
||||
struct mm_struct *mm = current->mm;
|
||||
|
||||
@@ -1507,7 +1507,7 @@ static struct mm_struct *dup_mm(struct task_struct *tsk,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
|
||||
static int copy_mm(u64 clone_flags, struct task_struct *tsk)
|
||||
{
|
||||
struct mm_struct *mm, *oldmm;
|
||||
|
||||
@@ -1545,7 +1545,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
|
||||
static int copy_fs(u64 clone_flags, struct task_struct *tsk)
|
||||
{
|
||||
struct fs_struct *fs = current->fs;
|
||||
if (clone_flags & CLONE_FS) {
|
||||
@@ -1566,7 +1566,7 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int copy_files(unsigned long clone_flags, struct task_struct *tsk,
|
||||
static int copy_files(u64 clone_flags, struct task_struct *tsk,
|
||||
int no_files)
|
||||
{
|
||||
struct files_struct *oldf, *newf;
|
||||
@@ -1645,7 +1645,7 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
|
||||
posix_cputimers_group_init(pct, cpu_limit);
|
||||
}
|
||||
|
||||
static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
|
||||
static int copy_signal(u64 clone_flags, struct task_struct *tsk)
|
||||
{
|
||||
struct signal_struct *sig;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ static inline struct nsproxy *create_nsproxy(void)
|
||||
* Return the newly created nsproxy. Do not attach this to the task,
|
||||
* leave it to the caller to do proper locking and attach it to task.
|
||||
*/
|
||||
static struct nsproxy *create_new_namespaces(unsigned long flags,
|
||||
static struct nsproxy *create_new_namespaces(u64 flags,
|
||||
struct task_struct *tsk, struct user_namespace *user_ns,
|
||||
struct fs_struct *new_fs)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
|
||||
* called from clone. This now handles copy for nsproxy and all
|
||||
* namespaces therein.
|
||||
*/
|
||||
int copy_namespaces(unsigned long flags, struct task_struct *tsk)
|
||||
int copy_namespaces(u64 flags, struct task_struct *tsk)
|
||||
{
|
||||
struct nsproxy *old_ns = tsk->nsproxy;
|
||||
struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
|
||||
|
||||
@@ -171,7 +171,7 @@ static void destroy_pid_namespace_work(struct work_struct *work)
|
||||
} while (ns != &init_pid_ns && refcount_dec_and_test(&ns->ns.count));
|
||||
}
|
||||
|
||||
struct pid_namespace *copy_pid_ns(unsigned long flags,
|
||||
struct pid_namespace *copy_pid_ns(u64 flags,
|
||||
struct user_namespace *user_ns, struct pid_namespace *old_ns)
|
||||
{
|
||||
if (!(flags & CLONE_NEWPID))
|
||||
|
||||
@@ -4472,7 +4472,7 @@ int wake_up_state(struct task_struct *p, unsigned int state)
|
||||
* __sched_fork() is basic setup which is also used by sched_init() to
|
||||
* initialize the boot CPU's idle task.
|
||||
*/
|
||||
static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
|
||||
static void __sched_fork(u64 clone_flags, struct task_struct *p)
|
||||
{
|
||||
p->on_rq = 0;
|
||||
|
||||
@@ -4707,7 +4707,7 @@ late_initcall(sched_core_sysctl_init);
|
||||
/*
|
||||
* fork()/clone()-time setup:
|
||||
*/
|
||||
int sched_fork(unsigned long clone_flags, struct task_struct *p)
|
||||
int sched_fork(u64 clone_flags, struct task_struct *p)
|
||||
{
|
||||
__sched_fork(clone_flags, p);
|
||||
/*
|
||||
|
||||
@@ -3542,7 +3542,7 @@ static void task_numa_work(struct callback_head *work)
|
||||
}
|
||||
}
|
||||
|
||||
void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
|
||||
void init_numa_balancing(u64 clone_flags, struct task_struct *p)
|
||||
{
|
||||
int mm_users = 0;
|
||||
struct mm_struct *mm = p->mm;
|
||||
|
||||
@@ -1935,12 +1935,12 @@ extern void sched_setnuma(struct task_struct *p, int node);
|
||||
extern int migrate_task_to(struct task_struct *p, int cpu);
|
||||
extern int migrate_swap(struct task_struct *p, struct task_struct *t,
|
||||
int cpu, int scpu);
|
||||
extern void init_numa_balancing(unsigned long clone_flags, struct task_struct *p);
|
||||
extern void init_numa_balancing(u64 clone_flags, struct task_struct *p);
|
||||
|
||||
#else /* !CONFIG_NUMA_BALANCING: */
|
||||
|
||||
static inline void
|
||||
init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
|
||||
init_numa_balancing(u64 clone_flags, struct task_struct *p)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,
|
||||
*
|
||||
* Return: timens_for_children namespace or ERR_PTR.
|
||||
*/
|
||||
struct time_namespace *copy_time_ns(unsigned long flags,
|
||||
struct time_namespace *copy_time_ns(u64 flags,
|
||||
struct user_namespace *user_ns, struct time_namespace *old_ns)
|
||||
{
|
||||
if (!(flags & CLONE_NEWTIME))
|
||||
|
||||
@@ -86,7 +86,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
|
||||
* utsname of this process won't be seen by parent, and vice
|
||||
* versa.
|
||||
*/
|
||||
struct uts_namespace *copy_utsname(unsigned long flags,
|
||||
struct uts_namespace *copy_utsname(u64 flags,
|
||||
struct user_namespace *user_ns, struct uts_namespace *old_ns)
|
||||
{
|
||||
struct uts_namespace *new_ns;
|
||||
|
||||
Reference in New Issue
Block a user