8000 Fix sanitizer-common build with glibc 2.31 · swiftlang/llvm-project@c5e7d42 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5e7d42

Browse files
eugenisDan Liew
authored andcommitted
Fix sanitizer-common build with glibc 2.31
Summary: As mentioned in D69104, glibc changed ABI recently with the [[ https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2f959dfe849e0646e27403f2e4091536496ac0f0| 2f959dfe ]] change. D69104 dealt with just 32-bit ARM, but that is just one of the many affected architectures. E.g. x86_64, i?86, riscv64, sparc 32-bit, s390 31-bit are affected too (and various others). This patch instead of adding a long list of further architectures that wouldn't be checked ever next to arm 32-bit changes the structures to match the 2.31 layout and performs the checking on Linux for ipc_perm mode position/size only on non-Linux or on Linux with glibc 2.31 or later. I think this matches what is done for aarch64 already. If needed, we could list architectures that haven't changed ABI (e.g. powerpc), so that they would be checked even with older glibcs. AFAIK sanitizers don't actually use ipc_perm.mode and so all they care about is the size and alignment of the whole structure. Note, s390 31-bit and arm 32-bit big-endian changed ABI even further, there will now be shmctl with old symbol version and shmctl@@GLIBC_2.31 which will be incompatible. I'm afraid this isn't really solvable unless the sanitizer libraries are symbol versioned and use matching symbol versions to glibc symbols for stuff they intercept, plus use dlvsym. This patch doesn't try to address that. Patch by Jakub Jelinek. Reviewers: kcc, eugenis, dvyukov Reviewed By: eugenis Subscribers: jyknight, kristof.beyls, fedor.sergeev, simoncook, PkmX, s.egerton, steven.zhang, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70662 (cherry-picked from 947f969)
1 parent 2767ae5 commit c5e7d42

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
11261126
CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
11271127
CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
11281128
CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
1129-
#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
1130-
/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */
1129+
#if !SANITIZER_LINUX || __GLIBC_PREREQ(2, 31)
1130+
/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit
1131+
on many architectures. */
11311132
CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
11321133
#endif
11331134

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,13 @@ namespace __sanitizer {
203203
u64 __unused1;
204204
u64 __unused2;
205205
#elif defined(__sparc__)
206-
#if defined(__arch64__)
207206
unsigned mode;
208-
unsigned short __pad1;
209-
#else
210-
unsigned short __pad1;
211-
unsigned short mode;
212207
unsigned short __pad2;
213-
#endif
214208
unsigned short __seq;
215209
unsigned long long __unused1;
216210
unsigned long long __unused2;
217-
#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__)
218-
unsigned int mode;
219-
unsigned short __seq;
220-
unsigned short __pad1;
221-
unsigned long __unused1;
222-
unsigned long __unused2;
223211
#else
224-
unsigned short mode;
225-
unsigned short __pad1;
212+
unsigned int mode;
226213
unsigned short __seq;
227214
unsigned short __pad2;
228215
#if defined(__x86_64__) && !defined(_LP64)

0 commit comments

Comments
 (0)
0