Skip to content

Commit d61ad67

Browse files
committed
[PR] vitalybuka - Ensure we read O_TMPFILE as well
1 parent 5a4555a commit d61ad67

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
5858
} // namespace
5959

6060
// Filesystem
61+
static bool open_reads_va_args(int oflag) {
62+
#ifdef O_TMPFILE
63+
return (oflag & (O_CREAT | O_TMPFILE)) != 0;
64+
#else
65+
return (oflag & O_CREAT) != 0;
66+
#endif
67+
}
6168

6269
INTERCEPTOR(int, open, const char *path, int oflag, ...) {
6370
// TODO Establish whether we should intercept here if the flag contains
6471
// O_NONBLOCK
6572
__rtsan_notify_intercepted_call("open");
6673

67-
if (oflag & O_CREAT) {
74+
if (open_reads_va_args(oflag)) {
6875
va_list args;
6976
va_start(args, oflag);
7077
const mode_t mode = va_arg(args, int);
@@ -99,7 +106,7 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
99106
// O_NONBLOCK
100107
__rtsan_notify_intercepted_call("openat");
101108

102-
if (oflag & O_CREAT) {
109+
if (open_reads_va_args(oflag)) {
103110
va_list args;
104111
va_start(args, oflag);
105112
const mode_t mode = va_arg(args, int);

0 commit comments

Comments
 (0)