|
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"
|
@@ -1613,47 +1614,40 @@ TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) {
|
1613 | 1614 | FdAccess(thr, pc, fd);
|
1614 | 1615 | return REAL(__fxstat)(version, fd, buf);
|
1615 | 1616 | }
|
1616 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat) |
| 1617 | + |
| 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 | +} |
| 1624 | +#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat); TSAN_INTERCEPT(__fxstat64) |
1617 | 1625 | #else
|
1618 | 1626 | #define TSAN_MAYBE_INTERCEPT___FXSTAT
|
1619 | 1627 | #endif
|
1620 | 1628 |
|
| 1629 | +#if !SANITIZER_GLIBC || __GLIBC_PREREQ(2, 33) |
1621 | 1630 | TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
|
1622 |
| -#if SANITIZER_GLIBC |
1623 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat, 0, fd, buf); |
1624 |
| - if (fd > 0) |
1625 |
| - FdAccess(thr, pc, fd); |
1626 |
| - return REAL(__fxstat)(0, fd, buf); |
1627 |
| -#else |
1628 | 1631 | SCOPED_TSAN_INTERCEPTOR(fstat, fd, buf);
|
1629 | 1632 | if (fd > 0)
|
1630 | 1633 | FdAccess(thr, pc, fd);
|
1631 | 1634 | return REAL(fstat)(fd, buf);
|
1632 |
| -#endif |
1633 |
| -} |
1634 |
| - |
1635 |
| -#if SANITIZER_GLIBC |
1636 |
| -TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) { |
1637 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf); |
1638 |
| - if (fd > 0) |
1639 |
| - FdAccess(thr, pc, fd); |
1640 |
| - return REAL(__fxstat64)(version, fd, buf); |
1641 | 1635 | }
|
1642 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 TSAN_INTERCEPT(__fxstat64) |
| 1636 | +# define TSAN_MAYBE_INTERCEPT_FSTAT TSAN_INTERCEPT(fstat) |
1643 | 1637 | #else
|
1644 |
| -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 |
| 1638 | +# define TSAN_MAYBE_INTERCEPT_FSTAT |
1645 | 1639 | #endif
|
1646 | 1640 |
|
1647 |
| -#if SANITIZER_GLIBC |
| 1641 | +#if __GLIBC_PREREQ(2, 33) |
1648 | 1642 | TSAN_INTERCEPTOR(int, fstat64, int fd, void *buf) {
|
1649 |
| - SCOPED_TSAN_INTERCEPTOR(__fxstat64, 0, fd, buf); |
| 1643 | + SCOPED_TSAN_INTERCEPTOR(fstat64, fd, buf); |
1650 | 1644 | if (fd > 0)
|
1651 | 1645 | FdAccess(thr, pc, fd);
|
1652 |
| - return REAL(__fxstat64)(0, fd, buf); |
| 1646 | + return REAL(fstat64)(fd, buf); |
1653 | 1647 | }
|
1654 |
| -#define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
| 1648 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
1655 | 1649 | #else
|
1656 |
| -#define TSAN_MAYBE_INTERCEPT_FSTAT64 |
| 1650 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 |
1657 | 1651 | #endif
|
1658 | 1652 |
|
1659 | 1653 | TSAN_INTERCEPTOR(int, open, const char *name, int oflag, ...) {
|
@@ -2950,10 +2944,9 @@ void InitializeInterceptors() {
|
2950 | 2944 |
|
2951 | 2945 | TSAN_INTERCEPT(pthread_once);
|
2952 | 2946 |
|
2953 |
| - TSAN_INTERCEPT(fstat); |
2954 | 2947 | TSAN_MAYBE_INTERCEPT___FXSTAT;
|
| 2948 | + TSAN_MAYBE_INTERCEPT_FSTAT; |
2955 | 2949 | TSAN_MAYBE_INTERCEPT_FSTAT64;
|
2956 |
| - TSAN_MAYBE_INTERCEPT___FXSTAT64; |
2957 | 2950 | TSAN_INTERCEPT(open);
|
2958 | 2951 | TSAN_MAYBE_INTERCEPT_OPEN64;
|
2959 | 2952 | TSAN_INTERCEPT(creat);
|
|
0 commit comments