Skip to content

Commit d949ac6

Browse files
authored
[compiler-rt] openat2 syscall interception. (llvm#153846)
1 parent c985a1a commit d949ac6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ struct sanitizer_kernel_sockaddr {
143143
char sa_data[14];
144144
};
145145

146+
struct sanitizer_kernel_open_how {
147+
u64 flags;
148+
u64 mode;
149+
u64 resolve;
150+
};
151+
146152
// Real sigset size is always passed as a syscall argument.
147153
// Declare it "void" to catch sizeof(kernel_sigset_t).
148154
typedef void kernel_sigset_t;
@@ -2843,6 +2849,18 @@ PRE_SYSCALL(openat)(long dfd, const void *filename, long flags, long mode) {
28432849
POST_SYSCALL(openat)
28442850
(long res, long dfd, const void *filename, long flags, long mode) {}
28452851

2852+
PRE_SYSCALL(openat2)(long dfd, const void* filename,
2853+
const sanitizer_kernel_open_how* how, uptr howlen) {
2854+
if (filename)
2855+
PRE_READ(filename, __sanitizer::internal_strlen((const char*)filename) + 1);
2856+
2857+
if (how)
2858+
PRE_READ(how, howlen);
2859+
}
2860+
2861+
POST_SYSCALL(openat2)(long res, long dfd, const void* filename,
2862+
const sanitizer_kernel_open_how* how, uptr howlen) {}
2863+
28462864
PRE_SYSCALL(newfstatat)
28472865
(long dfd, const void *filename, void *statbuf, long flag) {
28482866
if (filename)

0 commit comments

Comments
 (0)