[compiler-rt] [compiler-rt] openat2 syscall interception. (PR #153846)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 18:13:35 PDT 2025
https://github.com/devnexen updated https://github.com/llvm/llvm-project/pull/153846
>From 767a7c4b085740efc9e3bb529138fd611209a68a Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Fri, 15 Aug 2025 18:47:22 +0100
Subject: [PATCH] [compiler-rt] openat2 syscall interception.
---
.../sanitizer_common_syscalls.inc | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 521fc116f2888..cead831aa06f9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -143,6 +143,12 @@ struct sanitizer_kernel_sockaddr {
char sa_data[14];
};
+struct sanitizer_kernel_open_how {
+ u64 flags;
+ u64 mode;
+ u64 resolve;
+};
+
// Real sigset size is always passed as a syscall argument.
// Declare it "void" to catch sizeof(kernel_sigset_t).
typedef void kernel_sigset_t;
@@ -2843,6 +2849,18 @@ PRE_SYSCALL(openat)(long dfd, const void *filename, long flags, long mode) {
POST_SYSCALL(openat)
(long res, long dfd, const void *filename, long flags, long mode) {}
+PRE_SYSCALL(openat2)(long dfd, const void* filename,
+ const sanitizer_kernel_open_how* how, uptr howlen) {
+ if (filename)
+ PRE_READ(filename, __sanitizer::internal_strlen((const char *)filename) + 1);
+
+ if (how)
+ PRE_READ(how, howlen);
+}
+
+POST_SYSCALL(openat2)(long res, long dfd, const void* filename,
+ const sanitizer_kernel_open_how* how, uptr howlen) {}
+
PRE_SYSCALL(newfstatat)
(long dfd, const void *filename, void *statbuf, long flag) {
if (filename)
More information about the llvm-commits
mailing list