[compiler-rt] r179592 - [sanitizer] Implement wait4 and waitpid syscall hooks.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Apr 16 06:06:20 PDT 2013
Author: eugenis
Date: Tue Apr 16 08:06:20 2013
New Revision: 179592
URL: http://llvm.org/viewvc/llvm-project?rev=179592&view=rev
Log:
[sanitizer] Implement wait4 and waitpid syscall hooks.
Modified:
compiler-rt/trunk/include/sanitizer/linux_syscall_hooks.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
Modified: compiler-rt/trunk/include/sanitizer/linux_syscall_hooks.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/sanitizer/linux_syscall_hooks.h?rev=179592&r1=179591&r2=179592&view=diff
==============================================================================
--- compiler-rt/trunk/include/sanitizer/linux_syscall_hooks.h (original)
+++ compiler-rt/trunk/include/sanitizer/linux_syscall_hooks.h Tue Apr 16 08:06:20 2013
@@ -29,11 +29,15 @@ void __sanitizer_syscall_pre_rt_sigpendi
void __sanitizer_syscall_pre_getdents(int fd, void *dirp, int count);
void __sanitizer_syscall_pre_getdents64(int fd, void *dirp, int count);
void __sanitizer_syscall_pre_recvmsg(int sockfd, void *msg, int flags);
+void __sanitizer_syscall_pre_wait4(int pid, int* status, int options, void* r);
+void __sanitizer_syscall_pre_waitpid(int pid, int *status, int options);
void __sanitizer_syscall_post_rt_sigpending(long res, void *p, size_t s);
void __sanitizer_syscall_post_getdents(long res, int fd, void *dirp, int count);
void __sanitizer_syscall_post_getdents64(long res, int fd, void *dirp, int count);
void __sanitizer_syscall_post_recvmsg(long res, int sockfd, void *msg, int flags);
+void __sanitizer_syscall_post_wait4(long res, int pid, int* status, int options, void* r);
+void __sanitizer_syscall_post_waitpid(long res, int pid, int *status, int options);
// And now a few syscalls we don't handle yet.
@@ -408,11 +412,10 @@ void __sanitizer_syscall_post_recvmsg(lo
#define __sanitizer_syscall_pre_vm86old(...)
#define __sanitizer_syscall_pre_vmsplice(...)
#define __sanitizer_syscall_pre_vserver(...)
-#define __sanitizer_syscall_pre_wait4(...)
#define __sanitizer_syscall_pre_waitid(...)
-#define __sanitizer_syscall_pre_waitpid(...)
#define __sanitizer_syscall_pre_write(...)
#define __sanitizer_syscall_pre_writev(...)
+
#define __sanitizer_syscall_post_accept4(res, ...)
#define __sanitizer_syscall_post_accept(res, ...)
#define __sanitizer_syscall_post_access(res, ...)
@@ -784,9 +787,7 @@ void __sanitizer_syscall_post_recvmsg(lo
#define __sanitizer_syscall_post_vm86(res, ...)
#define __sanitizer_syscall_post_vmsplice(res, ...)
#define __sanitizer_syscall_post_vserver(res, ...)
-#define __sanitizer_syscall_post_wait4(res, ...)
#define __sanitizer_syscall_post_waitid(res, ...)
-#define __sanitizer_syscall_post_waitpid(res, ...)
#define __sanitizer_syscall_post_write(res, ...)
#define __sanitizer_syscall_post_writev(res, ...)
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc?rev=179592&r1=179591&r2=179592&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc Tue Apr 16 08:06:20 2013
@@ -56,6 +56,16 @@ struct sanitizer_kernel_msghdr {
unsigned msg_flags;
};
+struct sanitizer_kernel_timeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+struct sanitizer_kernel_rusage {
+ struct sanitizer_kernel_timeval ru_timeval[2];
+ long ru_long[14];
+};
+
PRE_SYSCALL(recvmsg)(int sockfd, struct sanitizer_kernel_msghdr *msg,
int flags) {
PRE_READ(msg, sizeof(*msg));
@@ -92,6 +102,34 @@ POST_SYSCALL(getdents64)(long res, int f
POST_WRITE(dirp, res);
}
+PRE_SYSCALL(wait4)(int pid, int *status, int options,
+ struct sanitizer_kernel_rusage *r) {
+ if (status)
+ PRE_WRITE(status, sizeof(*status));
+ if (r)
+ PRE_WRITE(r, sizeof(*r));
+}
+
+POST_SYSCALL(wait4)(long res, int pid, int *status, int options,
+ struct sanitizer_kernel_rusage *r) {
+ if (res > 0) {
+ if (status)
+ POST_WRITE(status, sizeof(*status));
+ if (r)
+ POST_WRITE(r, sizeof(*r));
+ }
+}
+
+PRE_SYSCALL(waitpid)(int pid, int *status, int options) {
+ if (status)
+ PRE_WRITE(status, sizeof(*status));
+}
+
+POST_SYSCALL(waitpid)(long res, int pid, int *status, int options) {
+ if (res > 0 && status)
+ POST_WRITE(status, sizeof(*status));
+}
+
} // extern "C"
#undef PRE_SYSCALL
More information about the llvm-commits
mailing list