[compiler-rt] r190161 - [sanitizer] Avoid including any system headers in the system-header-free part of the runtime library.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Sep 6 08:34:17 PDT 2013
Author: eugenis
Date: Fri Sep 6 10:34:17 2013
New Revision: 190161
URL: http://llvm.org/viewvc/llvm-project?rev=190161&view=rev
Log:
[sanitizer] Avoid including any system headers in the system-header-free part of the runtime library.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
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=190161&r1=190160&r2=190161&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc Fri Sep 6 10:34:17 2013
@@ -284,7 +284,8 @@ POST_SYSCALL(getsid)(long res, long pid)
PRE_SYSCALL(getgroups)(long gidsetsize, void *grouplist) {}
-POST_SYSCALL(getgroups)(long res, long gidsetsize, __kernel_gid_t *grouplist) {
+POST_SYSCALL(getgroups)(long res, long gidsetsize,
+ __sanitizer___kernel_gid_t *grouplist) {
if (res >= 0) {
if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist));
}
@@ -330,11 +331,12 @@ PRE_SYSCALL(setsid)() {}
POST_SYSCALL(setsid)(long res) {}
-PRE_SYSCALL(setgroups)(long gidsetsize, __kernel_gid_t *grouplist) {
+PRE_SYSCALL(setgroups)(long gidsetsize, __sanitizer___kernel_gid_t *grouplist) {
if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
}
-POST_SYSCALL(setgroups)(long res, long gidsetsize, __kernel_gid_t *grouplist) {}
+POST_SYSCALL(setgroups)(long res, long gidsetsize,
+ __sanitizer___kernel_gid_t *grouplist) {}
PRE_SYSCALL(acct)(const void *name) {
if (name)
@@ -1267,7 +1269,7 @@ POST_SYSCALL(io_cancel)(long res, long c
PRE_SYSCALL(sendfile)(long out_fd, long in_fd, void *offset, long count) {}
POST_SYSCALL(sendfile)(long res, long out_fd, long in_fd,
- __kernel_off_t *offset, long count) {
+ __sanitizer___kernel_off_t *offset, long count) {
if (res >= 0) {
if (offset) POST_WRITE(offset, sizeof(*offset));
}
@@ -1276,7 +1278,7 @@ POST_SYSCALL(sendfile)(long res, long ou
PRE_SYSCALL(sendfile64)(long out_fd, long in_fd, void *offset, long count) {}
POST_SYSCALL(sendfile64)(long res, long out_fd, long in_fd,
- __kernel_loff_t *offset, long count) {
+ __sanitizer___kernel_loff_t *offset, long count) {
if (res >= 0) {
if (offset) POST_WRITE(offset, sizeof(*offset));
}
@@ -1388,8 +1390,9 @@ POST_SYSCALL(setresuid16)(long res, long
PRE_SYSCALL(getresuid16)(void *ruid, void *euid, void *suid) {}
-POST_SYSCALL(getresuid16)(long res, __kernel_old_uid_t *ruid,
- __kernel_old_uid_t *euid, __kernel_old_uid_t *suid) {
+POST_SYSCALL(getresuid16)(long res, __sanitizer___kernel_old_uid_t *ruid,
+ __sanitizer___kernel_old_uid_t *euid,
+ __sanitizer___kernel_old_uid_t *suid) {
if (res >= 0) {
if (ruid) POST_WRITE(ruid, sizeof(*ruid));
if (euid) POST_WRITE(euid, sizeof(*euid));
@@ -1403,8 +1406,9 @@ POST_SYSCALL(setresgid16)(long res, long
PRE_SYSCALL(getresgid16)(void *rgid, void *egid, void *sgid) {}
-POST_SYSCALL(getresgid16)(long res, __kernel_old_gid_t *rgid,
- __kernel_old_gid_t *egid, __kernel_old_gid_t *sgid) {
+POST_SYSCALL(getresgid16)(long res, __sanitizer___kernel_old_gid_t *rgid,
+ __sanitizer___kernel_old_gid_t *egid,
+ __sanitizer___kernel_old_gid_t *sgid) {
if (res >= 0) {
if (rgid) POST_WRITE(rgid, sizeof(*rgid));
if (egid) POST_WRITE(egid, sizeof(*egid));
@@ -1420,21 +1424,23 @@ PRE_SYSCALL(setfsgid16)(long gid) {}
POST_SYSCALL(setfsgid16)(long res, long gid) {}
-PRE_SYSCALL(getgroups16)(long gidsetsize, __kernel_old_gid_t *grouplist) {}
+PRE_SYSCALL(getgroups16)(long gidsetsize,
+ __sanitizer___kernel_old_gid_t *grouplist) {}
POST_SYSCALL(getgroups16)(long res, long gidsetsize,
- __kernel_old_gid_t *grouplist) {
+ __sanitizer___kernel_old_gid_t *grouplist) {
if (res >= 0) {
if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist));
}
}
-PRE_SYSCALL(setgroups16)(long gidsetsize, __kernel_old_gid_t *grouplist) {
+PRE_SYSCALL(setgroups16)(long gidsetsize,
+ __sanitizer___kernel_old_gid_t *grouplist) {
if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
}
POST_SYSCALL(setgroups16)(long res, long gidsetsize,
- __kernel_old_gid_t *grouplist) {}
+ __sanitizer___kernel_old_gid_t *grouplist) {}
PRE_SYSCALL(getuid16)() {}
@@ -1807,11 +1813,13 @@ POST_SYSCALL(poll)(long res, __sanitizer
}
}
-PRE_SYSCALL(select)(long n, __kernel_fd_set *inp, __kernel_fd_set *outp,
- __kernel_fd_set *exp, void *tvp) {}
-
-POST_SYSCALL(select)(long res, long n, __kernel_fd_set *inp,
- __kernel_fd_set *outp, __kernel_fd_set *exp, void *tvp) {
+PRE_SYSCALL(select)(long n, __sanitizer___kernel_fd_set *inp,
+ __sanitizer___kernel_fd_set *outp,
+ __sanitizer___kernel_fd_set *exp, void *tvp) {}
+
+POST_SYSCALL(select)(long res, long n, __sanitizer___kernel_fd_set *inp,
+ __sanitizer___kernel_fd_set *outp,
+ __sanitizer___kernel_fd_set *exp, void *tvp) {
if (res >= 0) {
if (inp) POST_WRITE(inp, sizeof(*inp));
if (outp) POST_WRITE(outp, sizeof(*outp));
@@ -2587,11 +2595,14 @@ POST_SYSCALL(old_readdir)(long res, long
// Missing definition of 'struct old_linux_dirent'.
}
-PRE_SYSCALL(pselect6)(long arg0, __kernel_fd_set *arg1, __kernel_fd_set *arg2,
- __kernel_fd_set *arg3, void *arg4, void *arg5) {}
-
-POST_SYSCALL(pselect6)(long res, long arg0, __kernel_fd_set *arg1,
- __kernel_fd_set *arg2, __kernel_fd_set *arg3, void *arg4,
+PRE_SYSCALL(pselect6)(long arg0, __sanitizer___kernel_fd_set *arg1,
+ __sanitizer___kernel_fd_set *arg2,
+ __sanitizer___kernel_fd_set *arg3, void *arg4,
+ void *arg5) {}
+
+POST_SYSCALL(pselect6)(long res, long arg0, __sanitizer___kernel_fd_set *arg1,
+ __sanitizer___kernel_fd_set *arg2,
+ __sanitizer___kernel_fd_set *arg3, void *arg4,
void *arg5) {
if (res >= 0) {
if (arg1) POST_WRITE(arg1, sizeof(*arg1));
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=190161&r1=190160&r2=190161&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Fri Sep 6 10:34:17 2013
@@ -58,6 +58,7 @@
#include <linux/soundcard.h>
#include <linux/sysctl.h>
#include <linux/utsname.h>
+#include <linux/posix_types.h>
#endif
#if !SANITIZER_ANDROID
@@ -863,6 +864,14 @@ CHECK_SIZE_AND_OFFSET(__sysctl_args, old
CHECK_SIZE_AND_OFFSET(__sysctl_args, oldlenp);
CHECK_SIZE_AND_OFFSET(__sysctl_args, newval);
CHECK_SIZE_AND_OFFSET(__sysctl_args, newlen);
+
+CHECK_TYPE_SIZE(__kernel_uid_t);
+CHECK_TYPE_SIZE(__kernel_gid_t);
+CHECK_TYPE_SIZE(__kernel_old_uid_t);
+CHECK_TYPE_SIZE(__kernel_old_gid_t);
+CHECK_TYPE_SIZE(__kernel_off_t);
+CHECK_TYPE_SIZE(__kernel_loff_t);
+CHECK_TYPE_SIZE(__kernel_fd_set);
#endif
#endif // SANITIZER_LINUX || SANITIZER_MAC
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=190161&r1=190160&r2=190161&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Fri Sep 6 10:34:17 2013
@@ -17,12 +17,6 @@
#include "sanitizer_platform.h"
-#if SANITIZER_LINUX
-// This header is limited to declaration of __kernel_*_t, which are unlikely to
-// conflict with any sanitizer declarations.
-#include <linux/posix_types.h>
-#endif
-
namespace __sanitizer {
extern unsigned struct_utsname_sz;
extern unsigned struct_stat_sz;
@@ -166,6 +160,23 @@ namespace __sanitizer {
};
#endif
+#if SANITIZER_LINUX
+#ifdef _LP64
+ typedef unsigned __sanitizer___kernel_uid_t;
+ typedef unsigned __sanitizer___kernel_gid_t;
+#else
+ typedef unsigned short __sanitizer___kernel_uid_t;
+ typedef unsigned short __sanitizer___kernel_gid_t;
+#endif
+ typedef unsigned short __sanitizer___kernel_old_uid_t;
+ typedef unsigned short __sanitizer___kernel_old_gid_t;
+ typedef long __sanitizer___kernel_off_t;
+ typedef long long __sanitizer___kernel_loff_t;
+ typedef struct {
+ unsigned long fds_bits[1024 / (8 * sizeof(long))];
+ } __sanitizer___kernel_fd_set;
+#endif
+
// This thing depends on the platform. We are only interested in the upper
// limit. Verified with a compiler assert in .cc.
const int pthread_attr_t_max_sz = 128;
More information about the llvm-commits
mailing list