Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing/user_events: Track fork/exec/exit for mm lifetime

During tracefs discussions it was decided instead of requiring a mapping
within a user-process to track the lifetime of memory descriptors we
should hook the appropriate calls. Do this by adding the minimal stubs
required for task fork, exec, and exit. Currently this is just a NOP.
Future patches will implement these calls fully.

Link: https://lkml.kernel.org/r/20230328235219.203-3-beaub@linux.microsoft.com

Suggested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Beau Belgrave and committed by
Steven Rostedt (Google)
fd593511 e5a26a40

+29
+2
fs/exec.c
··· 65 65 #include <linux/syscall_user_dispatch.h> 66 66 #include <linux/coredump.h> 67 67 #include <linux/time_namespace.h> 68 + #include <linux/user_events.h> 68 69 69 70 #include <linux/uaccess.h> 70 71 #include <asm/mmu_context.h> ··· 1860 1859 current->fs->in_exec = 0; 1861 1860 current->in_execve = 0; 1862 1861 rseq_execve(current); 1862 + user_events_execve(current); 1863 1863 acct_update_integrals(current); 1864 1864 task_numa_free(current, false); 1865 1865 return retval;
+5
include/linux/sched.h
··· 69 69 struct signal_struct; 70 70 struct task_delay_info; 71 71 struct task_group; 72 + struct user_event_mm; 72 73 73 74 /* 74 75 * Task state bitmask. NOTE! These bits are also ··· 1527 1526 * none of these are justified. 1528 1527 */ 1529 1528 union rv_task_monitor rv[RV_PER_TASK_MONITORS]; 1529 + #endif 1530 + 1531 + #ifdef CONFIG_USER_EVENTS 1532 + struct user_event_mm *user_event_mm; 1530 1533 #endif 1531 1534 1532 1535 /*
+18
include/linux/user_events.h
··· 11 11 12 12 #include <uapi/linux/user_events.h> 13 13 14 + #ifdef CONFIG_USER_EVENTS 15 + struct user_event_mm { 16 + }; 17 + #endif 18 + 19 + static inline void user_events_fork(struct task_struct *t, 20 + unsigned long clone_flags) 21 + { 22 + } 23 + 24 + static inline void user_events_execve(struct task_struct *t) 25 + { 26 + } 27 + 28 + static inline void user_events_exit(struct task_struct *t) 29 + { 30 + } 31 + 14 32 #endif /* _LINUX_USER_EVENTS_H */
+2
kernel/exit.c
··· 68 68 #include <linux/kprobes.h> 69 69 #include <linux/rethook.h> 70 70 #include <linux/sysfs.h> 71 + #include <linux/user_events.h> 71 72 72 73 #include <linux/uaccess.h> 73 74 #include <asm/unistd.h> ··· 819 818 820 819 coredump_task_exit(tsk); 821 820 ptrace_event(PTRACE_EVENT_EXIT, code); 821 + user_events_exit(tsk); 822 822 823 823 validate_creds_for_do_exit(tsk); 824 824
+2
kernel/fork.c
··· 97 97 #include <linux/io_uring.h> 98 98 #include <linux/bpf.h> 99 99 #include <linux/stackprotector.h> 100 + #include <linux/user_events.h> 100 101 101 102 #include <asm/pgalloc.h> 102 103 #include <linux/uaccess.h> ··· 2506 2505 2507 2506 trace_task_newtask(p, clone_flags); 2508 2507 uprobe_copy_process(p, clone_flags); 2508 + user_events_fork(p, clone_flags); 2509 2509 2510 2510 copy_oom_score_adj(clone_flags, p); 2511 2511