-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[sanitizer_common] Implement address sanitizer on AIX: platform specific support #131866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
829ed78
075dd32
5040523
d994b0a
6bc803e
ada3b70
8641fca
35db409
f5ce2a7
12653e1
26bf8fe
cc252b9
b42ddff
d9b56c0
9603601
20074e3
af8e774
d797a87
5e4dc56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ | ||
!defined(__APPLE__) && !defined(_WIN32) && !defined(__Fuchsia__) && \ | ||
!(defined(__sun__) && defined(__svr4__)) && !defined(__HAIKU__) && \ | ||
!defined(__wasi__) | ||
!defined(__wasi__) && !defined(_AIX) | ||
# error "This operating system is not supported" | ||
#endif | ||
|
||
|
@@ -32,6 +32,12 @@ | |
# define SANITIZER_LINUX 0 | ||
#endif | ||
|
||
#if defined(_AIX) | ||
# define SANITIZER_AIX 1 | ||
#else | ||
# define SANITIZER_AIX 0 | ||
#endif | ||
|
||
#if defined(__GLIBC__) | ||
# define SANITIZER_GLIBC 1 | ||
#else | ||
|
@@ -151,7 +157,7 @@ | |
|
||
#define SANITIZER_POSIX \ | ||
(SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_APPLE || \ | ||
SANITIZER_NETBSD || SANITIZER_SOLARIS || SANITIZER_HAIKU) | ||
SANITIZER_NETBSD || SANITIZER_SOLARIS || SANITIZER_HAIKU || SANITIZER_AIX) | ||
|
||
#if __LP64__ || defined(_WIN64) | ||
# define SANITIZER_WORDSIZE 64 | ||
|
@@ -405,7 +411,9 @@ | |
// (ie. same as double) to 128-bit long double. On those, glibc symbols | ||
// involving long doubles come in two versions, and we need to pass the | ||
// correct one to dlvsym when intercepting them. | ||
#if SANITIZER_LINUX && (SANITIZER_S390 || SANITIZER_PPC32 || SANITIZER_PPC64V1) | ||
#if SANITIZER_LINUX && \ | ||
(SANITIZER_S390 || (SANITIZER_PPC32 && !SANITIZER_AIX) || \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change necessary? |
||
SANITIZER_PPC64V1) | ||
# define SANITIZER_NLDBL_VERSION "GLIBC_2.4" | ||
#endif | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
// Must go after undef _FILE_OFFSET_BITS. | ||
#include "sanitizer_platform.h" | ||
|
||
#if SANITIZER_LINUX || SANITIZER_APPLE || SANITIZER_HAIKU | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe sanitizer_platform_limits_aix.cpp ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why though? AIX is a POSIX platform and the logic (and structure) here seems to be common except for the usual type/structure size/layout differences. |
||
#if SANITIZER_LINUX || SANITIZER_APPLE || SANITIZER_HAIKU || SANITIZER_AIX | ||
// Must go after undef _FILE_OFFSET_BITS. | ||
#include "sanitizer_glibc_version.h" | ||
|
||
|
@@ -61,11 +61,11 @@ | |
#endif | ||
|
||
#if !SANITIZER_ANDROID | ||
#if !SANITIZER_HAIKU | ||
#include <sys/mount.h> | ||
#endif | ||
#include <sys/timeb.h> | ||
#include <utmpx.h> | ||
# if !SANITIZER_AIX && !SANITIZER_HAIKU | ||
# include <sys/mount.h> | ||
# endif | ||
# include <sys/timeb.h> | ||
# include <utmpx.h> | ||
#endif | ||
|
||
#if SANITIZER_LINUX | ||
|
@@ -112,11 +112,15 @@ typedef struct user_fpregs elf_fpregset_t; | |
#endif | ||
|
||
#if !SANITIZER_ANDROID | ||
#include <ifaddrs.h> | ||
#if !SANITIZER_HAIKU | ||
#include <sys/ucontext.h> | ||
#include <wordexp.h> | ||
#endif | ||
# if !SANITIZER_AIX | ||
# include <ifaddrs.h> | ||
# else | ||
# include <netinet/in.h> | ||
# endif | ||
# if !SANITIZER_HAIKU | ||
# include <sys/ucontext.h> | ||
# include <wordexp.h> | ||
# endif | ||
#endif | ||
|
||
#if SANITIZER_LINUX | ||
|
@@ -177,10 +181,21 @@ typedef struct user_fpregs elf_fpregset_t; | |
#include <sys/sockio.h> | ||
#endif | ||
|
||
#if SANITIZER_HAIKU | ||
#include <sys/sockio.h> | ||
#include <sys/ioctl.h> | ||
#endif | ||
# if SANITIZER_AIX | ||
# include <netinet/ip_mroute.h> | ||
# include <stropts.h> | ||
# include <sys/ioctl.h> | ||
# include <sys/statfs.h> | ||
# include <unistd.h> | ||
# if HAVE_RPC_XDR_H | ||
# include <tirpc/rpc/xdr.h> | ||
# endif | ||
# endif | ||
|
||
# if SANITIZER_HAIKU | ||
# include <sys/ioctl.h> | ||
# include <sys/sockio.h> | ||
# endif | ||
|
||
// Include these after system headers to avoid name clashes and ambiguities. | ||
# include "sanitizer_common.h" | ||
|
@@ -557,14 +572,45 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); | |
|
||
const unsigned IOCTL_NOT_PRESENT = 0; | ||
|
||
// On AIX, some variables are unsigned long types. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The vertical separation and intermixing between the changes here is not in a good shape for review. Suggestion: Add #if SANITIZER_AIX
using ioctl_alttype = uptr;
#else
using ioctl_alttype = unsigned;
#endif and change the specific lines affected by replacing |
||
# if SANITIZER_AIX | ||
uptr IOCTL_FIOASYNC = FIOASYNC; | ||
uptr IOCTL_FIONBIO = FIONBIO; | ||
uptr IOCTL_FIOSETOWN = FIOSETOWN; | ||
uptr IOCTL_SIOCSPGRP = SIOCSPGRP; | ||
uptr IOCTL_TIOCCONS = TIOCCONS; | ||
uptr IOCTL_TIOCMBIC = TIOCMBIC; | ||
uptr IOCTL_TIOCMBIS = TIOCMBIS; | ||
uptr IOCTL_TIOCMSET = TIOCMSET; | ||
uptr IOCTL_TIOCPKT = TIOCPKT; | ||
uptr IOCTL_TIOCSETD = TIOCSETD; | ||
uptr IOCTL_TIOCSPGRP = TIOCSPGRP; | ||
uptr IOCTL_TIOCSTI = TIOCSTI; | ||
uptr IOCTL_TIOCSWINSZ = TIOCSWINSZ; | ||
# else | ||
unsigned IOCTL_FIONBIO = FIONBIO; | ||
#if !SANITIZER_HAIKU | ||
# if !SANITIZER_HAIKU | ||
unsigned IOCTL_FIOASYNC = FIOASYNC; | ||
unsigned IOCTL_FIOSETOWN = FIOSETOWN; | ||
unsigned IOCTL_TIOCCONS = TIOCCONS; | ||
unsigned IOCTL_TIOCPKT = TIOCPKT; | ||
unsigned IOCTL_TIOCSETD = TIOCSETD; | ||
unsigned IOCTL_TIOCSTI = TIOCSTI; | ||
# endif | ||
unsigned IOCTL_SIOCSPGRP = SIOCSPGRP; | ||
unsigned IOCTL_TIOCMBIC = TIOCMBIC; | ||
unsigned IOCTL_TIOCMBIS = TIOCMBIS; | ||
unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ; | ||
unsigned IOCTL_TIOCMSET = TIOCMSET; | ||
unsigned IOCTL_TIOCSPGRP = TIOCSPGRP; | ||
# endif | ||
# if !SANITIZER_HAIKU | ||
unsigned IOCTL_FIOCLEX = FIOCLEX; | ||
unsigned IOCTL_FIOGETOWN = FIOGETOWN; | ||
unsigned IOCTL_FIONCLEX = FIONCLEX; | ||
unsigned IOCTL_FIOSETOWN = FIOSETOWN; | ||
#endif | ||
unsigned IOCTL_TIOCGETD = TIOCGETD; | ||
unsigned IOCTL_TIOCNOTTY = TIOCNOTTY; | ||
# endif | ||
unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI; | ||
unsigned IOCTL_SIOCATMARK = SIOCATMARK; | ||
unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI; | ||
|
@@ -584,30 +630,17 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); | |
unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC; | ||
unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU; | ||
unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK; | ||
unsigned IOCTL_SIOCSPGRP = SIOCSPGRP; | ||
|
||
#if !SANITIZER_HAIKU | ||
unsigned IOCTL_TIOCCONS = TIOCCONS; | ||
unsigned IOCTL_TIOCGETD = TIOCGETD; | ||
unsigned IOCTL_TIOCNOTTY = TIOCNOTTY; | ||
unsigned IOCTL_TIOCPKT = TIOCPKT; | ||
unsigned IOCTL_TIOCSETD = TIOCSETD; | ||
unsigned IOCTL_TIOCSTI = TIOCSTI; | ||
#endif | ||
|
||
unsigned IOCTL_TIOCEXCL = TIOCEXCL; | ||
unsigned IOCTL_TIOCGPGRP = TIOCGPGRP; | ||
unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ; | ||
unsigned IOCTL_TIOCMBIC = TIOCMBIC; | ||
unsigned IOCTL_TIOCMBIS = TIOCMBIS; | ||
unsigned IOCTL_TIOCMGET = TIOCMGET; | ||
unsigned IOCTL_TIOCMSET = TIOCMSET; | ||
unsigned IOCTL_TIOCNXCL = TIOCNXCL; | ||
unsigned IOCTL_TIOCOUTQ = TIOCOUTQ; | ||
# if !SANITIZER_AIX | ||
unsigned IOCTL_TIOCSCTTY = TIOCSCTTY; | ||
unsigned IOCTL_TIOCSPGRP = TIOCSPGRP; | ||
unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ; | ||
#if SANITIZER_LINUX && !SANITIZER_ANDROID | ||
# endif | ||
# if SANITIZER_LINUX && !SANITIZER_ANDROID | ||
unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT; | ||
unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT; | ||
#endif | ||
|
@@ -1003,8 +1036,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); | |
|
||
const int si_SEGV_MAPERR = SEGV_MAPERR; | ||
const int si_SEGV_ACCERR = SEGV_ACCERR; | ||
} // namespace __sanitizer | ||
|
||
} // namespace __sanitizer | ||
using namespace __sanitizer; | ||
|
||
COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t)); | ||
|
@@ -1115,11 +1147,13 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); | |
CHECK_SIZE_AND_OFFSET(dirent, d_ino); | ||
#if SANITIZER_APPLE | ||
CHECK_SIZE_AND_OFFSET(dirent, d_seekoff); | ||
#elif SANITIZER_FREEBSD || SANITIZER_HAIKU | ||
# elif SANITIZER_AIX | ||
CHECK_SIZE_AND_OFFSET(dirent, d_offset); | ||
# elif SANITIZER_FREEBSD || SANITIZER_HAIKU | ||
// There is no 'd_off' field on FreeBSD. | ||
#else | ||
# else | ||
CHECK_SIZE_AND_OFFSET(dirent, d_off); | ||
#endif | ||
# endif | ||
CHECK_SIZE_AND_OFFSET(dirent, d_reclen); | ||
|
||
#if SANITIZER_GLIBC | ||
|
@@ -1205,10 +1239,12 @@ CHECK_SIZE_AND_OFFSET(tm, tm_year); | |
CHECK_SIZE_AND_OFFSET(tm, tm_wday); | ||
CHECK_SIZE_AND_OFFSET(tm, tm_yday); | ||
CHECK_SIZE_AND_OFFSET(tm, tm_isdst); | ||
# if !SANITIZER_AIX | ||
CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff); | ||
CHECK_SIZE_AND_OFFSET(tm, tm_zone); | ||
# endif | ||
|
||
#if SANITIZER_LINUX | ||
# if SANITIZER_LINUX | ||
CHECK_TYPE_SIZE(mntent); | ||
CHECK_SIZE_AND_OFFSET(mntent, mnt_fsname); | ||
CHECK_SIZE_AND_OFFSET(mntent, mnt_dir); | ||
|
@@ -1258,7 +1294,7 @@ CHECK_TYPE_SIZE(clock_t); | |
CHECK_TYPE_SIZE(clockid_t); | ||
#endif | ||
|
||
#if !SANITIZER_ANDROID && !SANITIZER_HAIKU | ||
# if !SANITIZER_ANDROID && !SANITIZER_HAIKU && !SANITIZER_AIX | ||
CHECK_TYPE_SIZE(ifaddrs); | ||
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next); | ||
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specific to this patch: I am a bit concerned about this. If the CI or build system does not have this header, then changes that break the correspondence in layout would not be identified.
A separate patch should be posted to require the presence of this header (with an opt-out via CMake option). @vitalybuka, what process would you advise in terms of giving advance warning for buildbot maintainers?