tsan: intercept epoll_pwait2
It's a new syscall similar to epoll_pwait. Add a similar interceptor for it and add synchronization annotations in epoll_wait* syscall wrappers. Testing this is problematic b/c it's not present in glibc and the syscall itself may not be supported by the kernel. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D138574
This commit is contained in:
parent
875adb4007
commit
fbcdf4a4fb
|
@ -2106,6 +2106,7 @@ PRE_SYSCALL(epoll_wait)
|
||||||
POST_SYSCALL(epoll_wait)
|
POST_SYSCALL(epoll_wait)
|
||||||
(long res, long epfd, void *events, long maxevents, long timeout) {
|
(long res, long epfd, void *events, long maxevents, long timeout) {
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
|
COMMON_SYSCALL_FD_ACQUIRE(epfd);
|
||||||
if (events)
|
if (events)
|
||||||
POST_WRITE(events, res * struct_epoll_event_sz);
|
POST_WRITE(events, res * struct_epoll_event_sz);
|
||||||
}
|
}
|
||||||
|
@ -2122,6 +2123,7 @@ POST_SYSCALL(epoll_pwait)
|
||||||
(long res, long epfd, void *events, long maxevents, long timeout,
|
(long res, long epfd, void *events, long maxevents, long timeout,
|
||||||
const void *sigmask, long sigsetsize) {
|
const void *sigmask, long sigsetsize) {
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
|
COMMON_SYSCALL_FD_ACQUIRE(epfd);
|
||||||
if (events)
|
if (events)
|
||||||
POST_WRITE(events, res * struct_epoll_event_sz);
|
POST_WRITE(events, res * struct_epoll_event_sz);
|
||||||
}
|
}
|
||||||
|
@ -2142,6 +2144,7 @@ POST_SYSCALL(epoll_pwait2)
|
||||||
const sanitizer_kernel_timespec *timeout, const void *sigmask,
|
const sanitizer_kernel_timespec *timeout, const void *sigmask,
|
||||||
long sigsetsize) {
|
long sigsetsize) {
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
|
COMMON_SYSCALL_FD_ACQUIRE(epfd);
|
||||||
if (events)
|
if (events)
|
||||||
POST_WRITE(events, res * struct_epoll_event_sz);
|
POST_WRITE(events, res * struct_epoll_event_sz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1943,12 +1943,24 @@ TSAN_INTERCEPTOR(int, epoll_pwait, int epfd, void *ev, int cnt, int timeout,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TSAN_MAYBE_INTERCEPT_EPOLL \
|
TSAN_INTERCEPTOR(int, epoll_pwait2, int epfd, void *ev, int cnt, void *timeout,
|
||||||
TSAN_INTERCEPT(epoll_create); \
|
void *sigmask) {
|
||||||
TSAN_INTERCEPT(epoll_create1); \
|
SCOPED_TSAN_INTERCEPTOR(epoll_pwait2, epfd, ev, cnt, timeout, sigmask);
|
||||||
TSAN_INTERCEPT(epoll_ctl); \
|
if (epfd >= 0)
|
||||||
TSAN_INTERCEPT(epoll_wait); \
|
FdAccess(thr, pc, epfd);
|
||||||
TSAN_INTERCEPT(epoll_pwait)
|
int res = BLOCK_REAL(epoll_pwait2)(epfd, ev, cnt, timeout, sigmask);
|
||||||
|
if (res > 0 && epfd >= 0)
|
||||||
|
FdAcquire(thr, pc, epfd);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
# define TSAN_MAYBE_INTERCEPT_EPOLL \
|
||||||
|
TSAN_INTERCEPT(epoll_create); \
|
||||||
|
TSAN_INTERCEPT(epoll_create1); \
|
||||||
|
TSAN_INTERCEPT(epoll_ctl); \
|
||||||
|
TSAN_INTERCEPT(epoll_wait); \
|
||||||
|
TSAN_INTERCEPT(epoll_pwait); \
|
||||||
|
TSAN_INTERCEPT(epoll_pwait2)
|
||||||
#else
|
#else
|
||||||
#define TSAN_MAYBE_INTERCEPT_EPOLL
|
#define TSAN_MAYBE_INTERCEPT_EPOLL
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue