diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 557459befc44..cfb6180c8bae 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -58,6 +58,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -214,3 +215,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_release); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_has_work_ilocked); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_read_done); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_uid); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_user); + diff --git a/include/trace/hooks/user.h b/include/trace/hooks/user.h new file mode 100644 index 000000000000..773eed2ea75a --- /dev/null +++ b/include/trace/hooks/user.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM user +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_USER_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_USER_H +#include + +struct user_struct; +DECLARE_HOOK(android_vh_alloc_uid, + TP_PROTO(struct user_struct *user), + TP_ARGS(user)); + +DECLARE_HOOK(android_vh_free_user, + TP_PROTO(struct user_struct *up), + TP_ARGS(up)); + +#endif /* _TRACE_HOOK_USER_H */ +/* This part must be outside protection */ +#include + diff --git a/kernel/user.c b/kernel/user.c index e2cf8c22b539..1dfa806e8739 100644 --- a/kernel/user.c +++ b/kernel/user.c @@ -20,6 +20,8 @@ #include #include +#include + /* * userns count is 1 for root user, 1 for init_uts_ns, * and 1 for... ? @@ -152,6 +154,7 @@ static void user_epoll_free(struct user_struct *up) static void free_user(struct user_struct *up, unsigned long flags) __releases(&uidhash_lock) { + trace_android_vh_free_user(up); uid_hash_remove(up); spin_unlock_irqrestore(&uidhash_lock, flags); user_epoll_free(up); @@ -202,6 +205,7 @@ struct user_struct *alloc_uid(kuid_t uid) new->uid = uid; refcount_set(&new->__count, 1); + trace_android_vh_alloc_uid(new); if (user_epoll_alloc(new)) { kmem_cache_free(uid_cachep, new); return NULL;