summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-07-30 13:04:43 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-07-30 13:04:43 +0000
commit9fbd981f99d25e878adba159bee50ec15155bf23 (patch)
treeb963393f3820a052694d8c48b02fc92a03ba935e /compiler-rt/lib
parent807e1312611e10ac7f2c284cee89517c7fa5b697 (diff)
downloadbcm5719-llvm-9fbd981f99d25e878adba159bee50ec15155bf23.tar.gz
bcm5719-llvm-9fbd981f99d25e878adba159bee50ec15155bf23.zip
[sanitizer] read() syscall hook.
llvm-svn: 187414
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc5
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc9
2 files changed, 14 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc b/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc
index c716cfa29aa..afab18dba00 100644
--- a/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc
+++ b/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc
@@ -59,5 +59,10 @@ int main(int argc, char *argv[]) {
__msan_poison(buf, sizeof(buf));
__sanitizer_syscall_post_clock_gettime(-1, 0, buf);
assert(__msan_test_shadow(buf, sizeof(buf)) == 0);
+
+ __msan_poison(buf, sizeof(buf));
+ __sanitizer_syscall_post_read(5, 42, buf, 10);
+ assert(__msan_test_shadow(buf, sizeof(buf)) == 5);
+
return 0;
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 5a8b13fe442..5f4b24c0f59 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -161,6 +161,15 @@ POST_SYSCALL(clock_getres)(long res, int clk_id,
struct sanitizer_kernel_timespec *tp) {
if (res == 0 && tp) POST_WRITE(tp, sizeof(*tp));
}
+
+PRE_SYSCALL(read)(unsigned int fd, char *buf, uptr count) {
+ if (buf) PRE_WRITE(buf, count);
+}
+
+POST_SYSCALL(read)(long res, unsigned int fd, char *buf, uptr count) {
+ if (res > 0 && buf) POST_WRITE(buf, res);
+}
+
} // extern "C"
#undef PRE_SYSCALL
OpenPOWER on IntegriCloud