X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=include%2Flinux%2Fuser_events.h;h=2847f5a18a861e2268ce8d0a8b899511cd43ed80;hb=825a0714d2b3883d4f8ff64f6933fb73ee3f1834;hp=592a3fbed98e40a6177b31c4229d64b9bf81b59d;hpb=6022ec6ee2c3a16b26f218d7abb538afb839bd6d;p=linux-block.git diff --git a/include/linux/user_events.h b/include/linux/user_events.h index 592a3fbed98e..2847f5a18a86 100644 --- a/include/linux/user_events.h +++ b/include/linux/user_events.h @@ -1,54 +1,83 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2021, Microsoft Corporation. + * Copyright (c) 2022, Microsoft Corporation. * * Authors: * Beau Belgrave */ -#ifndef _UAPI_LINUX_USER_EVENTS_H -#define _UAPI_LINUX_USER_EVENTS_H -#include -#include +#ifndef _LINUX_USER_EVENTS_H +#define _LINUX_USER_EVENTS_H -#ifdef __KERNEL__ -#include -#else -#include -#endif +#include +#include +#include +#include +#include -#define USER_EVENTS_SYSTEM "user_events" -#define USER_EVENTS_PREFIX "u:" +#ifdef CONFIG_USER_EVENTS +struct user_event_mm { + struct list_head link; + struct list_head enablers; + struct mm_struct *mm; + struct user_event_mm *next; + refcount_t refcnt; + refcount_t tasks; + struct rcu_work put_rwork; +}; -/* Create dynamic location entry within a 32-bit value */ -#define DYN_LOC(offset, size) ((size) << 16 | (offset)) +extern void user_event_mm_dup(struct task_struct *t, + struct user_event_mm *old_mm); -/* - * Describes an event registration and stores the results of the registration. - * This structure is passed to the DIAG_IOCSREG ioctl, callers at a minimum - * must set the size and name_args before invocation. - */ -struct user_reg { +extern void user_event_mm_remove(struct task_struct *t); + +static inline void user_events_fork(struct task_struct *t, + unsigned long clone_flags) +{ + struct user_event_mm *old_mm; - /* Input: Size of the user_reg structure being used */ - __u32 size; + if (!t || !current->user_event_mm) + return; - /* Input: Pointer to string with event name, description and flags */ - __u64 name_args; + old_mm = current->user_event_mm; - /* Output: Bitwise index of the event within the status page */ - __u32 status_bit; + if (clone_flags & CLONE_VM) { + t->user_event_mm = old_mm; + refcount_inc(&old_mm->tasks); + return; + } - /* Output: Index of the event to use when writing data */ - __u32 write_index; -} __attribute__((__packed__)); + user_event_mm_dup(t, old_mm); +} -#define DIAG_IOC_MAGIC '*' +static inline void user_events_execve(struct task_struct *t) +{ + if (!t || !t->user_event_mm) + return; + + user_event_mm_remove(t); +} + +static inline void user_events_exit(struct task_struct *t) +{ + if (!t || !t->user_event_mm) + return; + + user_event_mm_remove(t); +} +#else +static inline void user_events_fork(struct task_struct *t, + unsigned long clone_flags) +{ +} -/* Requests to register a user_event */ -#define DIAG_IOCSREG _IOWR(DIAG_IOC_MAGIC, 0, struct user_reg*) +static inline void user_events_execve(struct task_struct *t) +{ +} -/* Requests to delete a user_event */ -#define DIAG_IOCSDEL _IOW(DIAG_IOC_MAGIC, 1, char*) +static inline void user_events_exit(struct task_struct *t) +{ +} +#endif /* CONFIG_USER_EVENTS */ -#endif /* _UAPI_LINUX_USER_EVENTS_H */ +#endif /* _LINUX_USER_EVENTS_H */