1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2022, Microsoft Corporation.
6 * Beau Belgrave <beaub@linux.microsoft.com>
9 #ifndef _LINUX_USER_EVENTS_H
10 #define _LINUX_USER_EVENTS_H
12 #include <linux/list.h>
13 #include <linux/refcount.h>
14 #include <linux/mm_types.h>
15 #include <linux/workqueue.h>
16 #include <uapi/linux/user_events.h>
18 #ifdef CONFIG_USER_EVENTS
19 struct user_event_mm
{
20 struct list_head mms_link
;
21 struct list_head enablers
;
23 /* Used for one-shot lists, protected by event_mutex */
24 struct user_event_mm
*next
;
27 struct rcu_work put_rwork
;
30 extern void user_event_mm_dup(struct task_struct
*t
,
31 struct user_event_mm
*old_mm
);
33 extern void user_event_mm_remove(struct task_struct
*t
);
35 static inline void user_events_fork(struct task_struct
*t
,
36 unsigned long clone_flags
)
38 struct user_event_mm
*old_mm
;
40 if (!t
|| !current
->user_event_mm
)
43 old_mm
= current
->user_event_mm
;
45 if (clone_flags
& CLONE_VM
) {
46 t
->user_event_mm
= old_mm
;
47 refcount_inc(&old_mm
->tasks
);
51 user_event_mm_dup(t
, old_mm
);
54 static inline void user_events_execve(struct task_struct
*t
)
56 if (!t
|| !t
->user_event_mm
)
59 user_event_mm_remove(t
);
62 static inline void user_events_exit(struct task_struct
*t
)
64 if (!t
|| !t
->user_event_mm
)
67 user_event_mm_remove(t
);
70 static inline void user_events_fork(struct task_struct
*t
,
71 unsigned long clone_flags
)
75 static inline void user_events_execve(struct task_struct
*t
)
79 static inline void user_events_exit(struct task_struct
*t
)
82 #endif /* CONFIG_USER_EVENTS */
84 #endif /* _LINUX_USER_EVENTS_H */