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

Unified · Split

include/trace/events/task.h+3−3
@@ -8,14 +8,14 @@ · 7 unmodified lines
88
99 TRACE_EVENT(task_newtask,
1010
11− TP_PROTO(struct task_struct *task, unsigned long clone_flags),
11+ TP_PROTO(struct task_struct *task, u64 clone_flags),
1212
1313 TP_ARGS(task, clone_flags),
1414
1515 TP_STRUCT__entry(
1616 __field( pid_t, pid)
1717 __array( char, comm, TASK_COMM_LEN)
18− __field( unsigned long, clone_flags)
18+ __field( u64, clone_flags)
1919 __field( short, oom_score_adj)
2020 ),
2121
@@ -26,7 +26,7 @@ TRACE_EVENT(task_newtask, · 4 unmodified lines
2626 __entry->oom_score_adj = task->signal->oom_score_adj;
2727 ),
2828
29− TP_printk("pid=%d comm=%s clone_flags=%lx oom_score_adj=%hd",
29+ TP_printk("pid=%d comm=%s clone_flags=%llx oom_score_adj=%hd",
3030 __entry->pid, __entry->comm,
3131 __entry->clone_flags, __entry->oom_score_adj)
3232 );