ANDROID: user: Add vendor hook to user for GKI purpose
Add the vendor hook to user.c, because of some speical cases related to our feature, we need to initialize the variables defined by ourselves in user_struct, so we add the hook at alloc_uid to make sure we can go to our own logic when the user_struct is about to initialize. Bug: 187458531 Signed-off-by: heshuai1 <heshuai1@xiaomi.com> Change-Id: I078484aac2c3d396aba5971d6d0f491652f3781c
This commit is contained in:
parent
9975da5f43
commit
c9b8fa644f
@ -60,6 +60,7 @@
|
||||
#include <trace/hooks/v4l2core.h>
|
||||
#include <trace/hooks/v4l2mc.h>
|
||||
#include <trace/hooks/scmi.h>
|
||||
#include <trace/hooks/user.h>
|
||||
|
||||
/*
|
||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||
@ -314,4 +315,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scmi_timeout_sync);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_new_ilb);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_pre);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_post);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_uid);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_user);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_balance_anon_file_reclaim);
|
||||
|
23
include/trace/hooks/user.h
Normal file
23
include/trace/hooks/user.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* 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 <linux/tracepoint.h>
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
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 <trace/define_trace.h>
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <linux/user_namespace.h>
|
||||
#include <linux/proc_ns.h>
|
||||
|
||||
#include <trace/hooks/user.h>
|
||||
|
||||
/*
|
||||
* userns count is 1 for root user, 1 for init_uts_ns,
|
||||
* and 1 for... ?
|
||||
@ -139,6 +141,7 @@ static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head *hashent)
|
||||
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);
|
||||
kmem_cache_free(uid_cachep, up);
|
||||
@ -190,6 +193,7 @@ struct user_struct *alloc_uid(kuid_t uid)
|
||||
|
||||
new->uid = uid;
|
||||
refcount_set(&new->__count, 1);
|
||||
trace_android_vh_alloc_uid(new);
|
||||
ratelimit_state_init(&new->ratelimit, HZ, 100);
|
||||
ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user