|
14 | 14 |
|
15 | 15 | #include "sanitizer_common/sanitizer_atomic.h"
|
16 | 16 | #include "sanitizer_common/sanitizer_errno.h"
|
| 17 | +#include "sanitizer_common/sanitizer_glibc_version.h" |
17 | 18 | #include "sanitizer_common/sanitizer_libc.h"
|
18 | 19 | #include "sanitizer_common/sanitizer_linux.h"
|
19 | 20 | #include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
|
@@ -1595,47 +1596,40 @@ TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) {
|
1595 | 1596 | FdAccess(thr, pc, fd);
|
1596 | 1597 | return REAL(__fxstat)(version, fd, buf);
|
1597 | 1598 | }
|
1598 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat) |
| 1599 | + |
| 1600 | +TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) { |
| 1601 | + SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf); |
| 1602 | + if (fd > 0) |
| 1603 | + FdAccess(thr, pc, fd); |
| 1604 | + return REAL(__fxstat64)(version, fd, buf); |
| 1605 | +} |
| 1606 | +#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat); TSAN_INTERCEPT(__fxstat64) |
1599 | 1607 | #else
|
1600 | 1608 | #define TSAN_MAYBE_INTERCEPT___FXSTAT
|
1601 | 1609 | #endif
|
1602 | 1610 |
|
| 1611 | +#if !SANITIZER_GLIBC || __GLIBC_PREREQ(2, 33) |
1603 | 1612 | TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
|
1604 |
| -#if SANITIZER_GLIBC |
1605 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat, 0, fd, buf); |
1606 |
| - if (fd > 0) |
1607 |
| - FdAccess(thr, pc, fd); |
1608 |
| - return REAL(__fxstat)(0, fd, buf); |
1609 |
| -#else |
1610 | 1613 | SCOPED_TSAN_INTERCEPTOR(fstat, fd, buf);
|
1611 | 1614 | if (fd > 0)
|
1612 | 1615 | FdAccess(thr, pc, fd);
|
1613 | 1616 | return REAL(fstat)(fd, buf);
|
1614 |
| -#endif |
1615 |
| -} |
1616 |
| - |
1617 |
| -#if SANITIZER_GLIBC |
1618 |
| -TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) { |
1619 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf); |
1620 |
| - if (fd > 0) |
1621 |
| - FdAccess(thr, pc, fd); |
1622 |
| - return REAL(__fxstat64)(version, fd, buf); |
1623 | 1617 | }
|
1624 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 TSAN_INTERCEPT(__fxstat64) |
| 1618 | +# define TSAN_MAYBE_INTERCEPT_FSTAT TSAN_INTERCEPT(fstat) |
1625 | 1619 | #else
|
1626 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 |
| 1620 | +# define TSAN_MAYBE_INTERCEPT_FSTAT |
1627 | 1621 | #endif
|
1628 | 1622 |
|
1629 |
| -#if SANITIZER_GLIBC |
| 1623 | +#if __GLIBC_PREREQ(2, 33) |
1630 | 1624 | TSAN_INTERCEPTOR(int, fstat64, int fd, void *buf) {
|
1631 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat64, 0, fd, buf); |
| 1625 | + SCOPED_TSAN_INTERCEPTOR(fstat64, fd, buf); |
1632 | 1626 | if (fd > 0)
|
1633 | 1627 | FdAccess(thr, pc, fd);
|
1634 |
| - return REAL(__fxstat64)(0, fd, buf); |
| 1628 | + return REAL(fstat64)(fd, buf); |
1635 | 1629 | }
|
1636 |
| -#define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
| 1630 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
1637 | 1631 | #else
|
1638 |
| -#define TSAN_MAYBE_INTERCEPT_FSTAT64 |
| 1632 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 |
1639 | 1633 | #endif
|
1640 | 1634 |
|
1641 | 1635 | TSAN_INTERCEPTOR(int, open, const char *name, int oflag, ...) {
|
@@ -2929,10 +2923,9 @@ void InitializeInterceptors() {
|
2929 | 2923 |
|
2930 | 2924 | TSAN_INTERCEPT(pthread_once);
|
2931 | 2925 |
|
2932 |
| - TSAN_INTERCEPT(fstat); |
2933 | 2926 | TSAN_MAYBE_INTERCEPT___FXSTAT;
|
| 2927 | + TSAN_MAYBE_INTERCEPT_FSTAT; |
2934 | 2928 | TSAN_MAYBE_INTERCEPT_FSTAT64;
|
2935 |
| - TSAN_MAYBE_INTERCEPT___FXSTAT64; |
2936 | 2929 | TSAN_INTERCEPT(open);
|
2937 | 2930 | TSAN_MAYBE_INTERCEPT_OPEN64;
|
2938 | 2931 | TSAN_INTERCEPT(creat);
|
|
0 commit comments