ANDROID: vendor_hooks: add vendor hook for nanosleep syscall

Through this vendor hook, we can get the timing to check
current running task for the validation of its credential
and nanosleep operations. through this we can filter some
app tasks which may fire the nanosleep events storm.

Bug: 396244637
Bug: 341618050
Change-Id: I644ac3d217930aa0a50966996e8001e27ce8a501
Signed-off-by: litao <tao.li@vivo.corp-partner.google.com>
(cherry picked from commit 1d9ed15534d4988da3ac56dd7892d37bf5f96847)
This commit is contained in:
litao
2024-05-20 15:02:36 +08:00
committed by Todd Kjos
parent 823bff6408
commit 4713550a59
3 changed files with 10 additions and 0 deletions
+1
View File
@@ -188,6 +188,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_set_affinity);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dc_send_copy);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dc_receive);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_nanosleep_syscall);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery_set);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index);
+6
View File
@@ -12,6 +12,8 @@
*/
struct file;
union bpf_attr;
struct timespec64;
DECLARE_HOOK(android_vh_check_mmap_file,
TP_PROTO(const struct file *file, unsigned long prot,
unsigned long flag, unsigned long ret),
@@ -25,6 +27,10 @@ DECLARE_HOOK(android_vh_check_bpf_syscall,
TP_PROTO(int cmd, const union bpf_attr *attr, unsigned int size),
TP_ARGS(cmd, attr, size));
DECLARE_HOOK(android_vh_check_nanosleep_syscall,
TP_PROTO(struct timespec64 *tu),
TP_ARGS(tu));
#endif /* _TRACE_HOOK_SYSCALL_CHECK_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+3
View File
@@ -46,6 +46,7 @@
#include <linux/uaccess.h>
#include <trace/events/timer.h>
#include <trace/hooks/syscall_check.h>
#include "tick-internal.h"
@@ -2173,6 +2174,7 @@ SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,
if (!timespec64_valid(&tu))
return -EINVAL;
trace_android_vh_check_nanosleep_syscall(&tu);
current->restart_block.fn = do_no_restart_syscall;
current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
current->restart_block.nanosleep.rmtp = rmtp;
@@ -2195,6 +2197,7 @@ SYSCALL_DEFINE2(nanosleep_time32, struct old_timespec32 __user *, rqtp,
if (!timespec64_valid(&tu))
return -EINVAL;
trace_android_vh_check_nanosleep_syscall(&tu);
current->restart_block.fn = do_no_restart_syscall;
current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
current->restart_block.nanosleep.compat_rmtp = rmtp;