From 996496b8eaf7131bc72971f346d7ee0720f609e7 Mon Sep 17 00:00:00 2001 From: Kuan-Ying Lee Date: Fri, 18 Jun 2021 13:28:11 +0800 Subject: [PATCH] ANDROID: syscall_check: add vendor hook for open syscall Through this vendor hook, we can get the timing to check current running task for the validation of its credential and open operation. Bug: 191291287 Signed-off-by: Kuan-Ying Lee Change-Id: Ia644ceb02dbc230ee1d25cad3630c2c3f908e41a (cherry picked from commit a7a3b31d5860bead8eec9e72a333351b8c2ac1ca) --- drivers/android/vendor_hooks.c | 1 + fs/open.c | 2 ++ include/trace/hooks/syscall_check.h | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 8f307fc66518..b98528fbc3e4 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -194,3 +194,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_before_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_after_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_is_initialized); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_mmap_file); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_file_open); diff --git a/fs/open.c b/fs/open.c index daa324606a41..0ec7f9a28014 100644 --- a/fs/open.c +++ b/fs/open.c @@ -34,6 +34,7 @@ #include #include "internal.h" +#include int do_truncate(struct user_namespace *mnt_userns, struct dentry *dentry, loff_t length, unsigned int time_attrs, struct file *filp) @@ -805,6 +806,7 @@ static int do_dentry_open(struct file *f, error = -ENODEV; goto cleanup_all; } + trace_android_vh_check_file_open(f); error = security_file_open(f); if (error) diff --git a/include/trace/hooks/syscall_check.h b/include/trace/hooks/syscall_check.h index edb80386511b..f21a52730111 100644 --- a/include/trace/hooks/syscall_check.h +++ b/include/trace/hooks/syscall_check.h @@ -17,6 +17,10 @@ DECLARE_HOOK(android_vh_check_mmap_file, unsigned long flag, unsigned long ret), TP_ARGS(file, prot, flag, ret)); +DECLARE_HOOK(android_vh_check_file_open, + TP_PROTO(const struct file *file), + TP_ARGS(file)); + #endif /* _TRACE_HOOK_SYSCALL_CHECK_H */ /* This part must be outside protection */ #include