From a7a3b31d5860bead8eec9e72a333351b8c2ac1ca 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 --- 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 3cff21655b80..b39c1a45587f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -348,3 +348,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb); 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 0aabf1728fde..7b47f2b93675 100644 --- a/fs/open.c +++ b/fs/open.c @@ -34,6 +34,7 @@ #include #include "internal.h" +#include int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, struct file *filp) @@ -800,6 +801,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