@@ -73,6 +73,25 @@ INTERCEPTOR(int, open, const char *path, int oflag, ...) {
73
73
return result;
74
74
}
75
75
76
+ #if SANITIZER_INTERCEPT_OPEN64
77
+ INTERCEPTOR (int , open64, const char *path, int oflag, ...) {
78
+ // TODO Establish whether we should intercept here if the flag contains
79
+ // O_NONBLOCK
80
+ __rtsan_expect_not_realtime (" open64" );
81
+
82
+ va_list args;
83
+ va_start (args, oflag);
84
+ const mode_t mode = va_arg (args, int );
85
+ va_end (args);
86
+
87
+ const int result = REAL (open64)(path, oflag, mode);
88
+ return result;
89
+ }
90
+ #define RTSAN_MAYBE_INTERCEPT_OPEN64 INTERCEPT_FUNCTION (open64)
91
+ #else
92
+ #define RTSAN_MAYBE_INTERCEPT_OPEN64
93
+ #endif // SANITIZER_INTERCEPT_OPEN64
94
+
76
95
INTERCEPTOR (int , openat, int fd, const char *path, int oflag, ...) {
77
96
// TODO Establish whether we should intercept here if the flag contains
78
97
// O_NONBLOCK
@@ -87,6 +106,25 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
87
106
return result;
88
107
}
89
108
109
+ #if SANITIZER_INTERCEPT_OPENAT64
110
+ INTERCEPTOR (int , openat64, int fd, const char *path, int oflag, ...) {
111
+ // TODO Establish whether we should intercept here if the flag contains
112
+ // O_NONBLOCK
113
+ __rtsan_expect_not_realtime (" openat64" );
114
+
115
+ va_list args;
116
+ va_start (args, oflag);
117
+ mode_t mode = va_arg (args, int );
118
+ va_end (args);
119
+
120
+ const int result = REAL (openat64)(fd, path, oflag, mode);
121
+ return result;
122
+ }
123
+ #define RTSAN_MAYBE_INTERCEPT_OPENAT64 INTERCEPT_FUNCTION (openat64)
124
+ #else
125
+ #define RTSAN_MAYBE_INTERCEPT_OPENAT64
126
+ #endif // SANITIZER_INTERCEPT_OPENAT64
127
+
90
128
INTERCEPTOR (int , creat, const char *path, mode_t mode) {
91
129
// TODO Establish whether we should intercept here if the flag contains
92
130
// O_NONBLOCK
@@ -95,6 +133,19 @@ INTERCEPTOR(int, creat, const char *path, mode_t mode) {
95
133
return result;
96
134
}
97
135
136
+ #if SANITIZER_INTERCEPT_CREAT64
137
+ INTERCEPTOR (int , creat64, const char *path, mode_t mode) {
138
+ // TODO Establish whether we should intercept here if the flag contains
139
+ // O_NONBLOCK
140
+ __rtsan_expect_not_realtime (" creat64" );
141
+ const int result = REAL (creat64)(path, mode);
142
+ return result;
143
+ }
144
+ #define RTSAN_MAYBE_INTERCEPT_CREAT64 INTERCEPT_FUNCTION (creat64)
145
+ #else
146
+ #define RTSAN_MAYBE_INTERCEPT_CREAT64
147
+ #endif // SANITIZER_INTERCEPT_CREAT64
148
+
98
149
INTERCEPTOR (int , fcntl, int filedes, int cmd, ...) {
99
150
__rtsan_expect_not_realtime (" fcntl" );
100
151
@@ -116,6 +167,32 @@ INTERCEPTOR(int, fcntl, int filedes, int cmd, ...) {
116
167
return result;
117
168
}
118
169
170
+ #if SANITIZER_INTERCEPT_FCNTL64
171
+ INTERCEPTOR (int , fcntl64, int filedes, int cmd, ...) {
172
+ __rtsan_expect_not_realtime (" fcntl64" );
173
+
174
+ va_list args;
175
+ va_start (args, cmd);
176
+
177
+ // Following precedent here. The linux source (fcntl.c, do_fcntl) accepts the
178
+ // final argument in a variable that will hold the largest of the possible
179
+ // argument types (pointers and ints are typical in fcntl) It is then assumed
180
+ // that the implementation of fcntl will cast it properly depending on cmd.
181
+ //
182
+ // This is also similar to what is done in
183
+ // sanitizer_common/sanitizer_common_syscalls.inc
184
+ const unsigned long arg = va_arg (args, unsigned long );
185
+ int result = REAL (fcntl64)(filedes, cmd, arg);
186
+
187
+ va_end (args);
188
+
189
+ return result;
190
+ }
191
+ #define RTSAN_MAYBE_INTERCEPT_FCNTL64 INTERCEPT_FUNCTION (fcntl64)
192
+ #else
193
+ #define RTSAN_MAYBE_INTERCEPT_FCNTL64
194
+ #endif // SANITIZER_INTERCEPT_FCNTL64
195
+
119
196
INTERCEPTOR (int , close, int filedes) {
120
197
__rtsan_expect_not_realtime (" close" );
121
198
return REAL (close )(filedes);
@@ -126,6 +203,16 @@ INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) {
126
203
return REAL (fopen )(path, mode);
127
204
}
128
205
206
+ #if SANITIZER_INTERCEPT_FOPEN64
207
+ INTERCEPTOR (FILE *, fopen64, const char *path, const char *mode) {
208
+ __rtsan_expect_not_realtime (" fopen64" );
209
+ return REAL (fopen64)(path, mode);
210
+ }
211
+ #define RTSAN_MAYBE_INTERCEPT_FOPEN64 INTERCEPT_FUNCTION (fopen64)
212
+ #else
213
+ #define RTSAN_MAYBE_INTERCEPT_FOPEN64
214
+ #endif // SANITIZER_INTERCEPT_FOPEN64
215
+
129
216
INTERCEPTOR (size_t , fread, void *ptr, size_t size, size_t nitems,
130
217
FILE *stream) {
131
218
__rtsan_expect_not_realtime (" fread" );
@@ -169,6 +256,16 @@ INTERCEPTOR(ssize_t, pread, int fd, void *buf, size_t count, off_t offset) {
169
256
return REAL (pread )(fd, buf, count, offset);
170
257
}
171
258
259
+ #if SANITIZER_INTERCEPT_PREAD64
260
+ INTERCEPTOR (ssize_t , pread64, int fd, void *buf, size_t count, off_t offset) {
261
+ __rtsan_expect_not_realtime (" pread64" );
262
+ return REAL (pread64)(fd, buf, count, offset);
263
+ }
264
+ #define RTSAN_MAYBE_INTERCEPT_PREAD64 INTERCEPT_FUNCTION (pread64)
265
+ #else
266
+ #define RTSAN_MAYBE_INTERCEPT_PREAD64
267
+ #endif // SANITIZER_INTERCEPT_PREAD64
268
+
172
269
INTERCEPTOR (ssize_t , readv, int fd, const struct iovec *iov, int iovcnt) {
173
270
__rtsan_expect_not_realtime (" readv" );
174
271
return REAL (readv)(fd, iov, iovcnt);
@@ -180,6 +277,17 @@ INTERCEPTOR(ssize_t, pwrite, int fd, const void *buf, size_t count,
180
277
return REAL (pwrite )(fd, buf, count, offset);
181
278
}
182
279
280
+ #if SANITIZER_INTERCEPT_PWRITE64
281
+ INTERCEPTOR (ssize_t , pwrite64, int fd, const void *buf, size_t count,
282
+ off_t offset) {
283
+ __rtsan_expect_not_realtime (" pwrite64" );
284
+ return REAL (pwrite64)(fd, buf, count, offset);
285
+ }
286
+ #define RTSAN_MAYBE_INTERCEPT_PWRITE64 INTERCEPT_FUNCTION (pwrite64)
287
+ #else
288
+ #define RTSAN_MAYBE_INTERCEPT_PWRITE64
289
+ #endif // SANITIZER_INTERCEPT_PWRITE64
290
+
183
291
INTERCEPTOR (ssize_t , writev, int fd, const struct iovec *iov, int iovcnt) {
184
292
__rtsan_expect_not_realtime (" writev" );
185
293
return REAL (writev)(fd, iov, iovcnt);
@@ -420,20 +528,27 @@ void __rtsan::InitializeInterceptors() {
420
528
#endif
421
529
422
530
INTERCEPT_FUNCTION (open );
531
+ RTSAN_MAYBE_INTERCEPT_OPEN64;
423
532
INTERCEPT_FUNCTION (openat );
533
+ RTSAN_MAYBE_INTERCEPT_OPENAT64;
424
534
INTERCEPT_FUNCTION (close );
425
535
INTERCEPT_FUNCTION (fopen );
536
+ RTSAN_MAYBE_INTERCEPT_FOPEN64;
426
537
INTERCEPT_FUNCTION (fread );
427
538
INTERCEPT_FUNCTION (read );
428
539
INTERCEPT_FUNCTION (write );
429
540
INTERCEPT_FUNCTION (pread );
541
+ RTSAN_MAYBE_INTERCEPT_PREAD64;
430
542
INTERCEPT_FUNCTION (readv);
431
543
INTERCEPT_FUNCTION (pwrite );
544
+ RTSAN_MAYBE_INTERCEPT_PWRITE64;
432
545
INTERCEPT_FUNCTION (writev);
433
546
INTERCEPT_FUNCTION (fwrite );
434
547
INTERCEPT_FUNCTION (fclose );
435
548
INTERCEPT_FUNCTION (fcntl );
549
+ RTSAN_MAYBE_INTERCEPT_FCNTL64;
436
550
INTERCEPT_FUNCTION (creat );
551
+ RTSAN_MAYBE_INTERCEPT_CREAT64;
437
552
INTERCEPT_FUNCTION (puts );
438
553
INTERCEPT_FUNCTION (fputs );
439
554
0 commit comments