[PATCH] Improve fix for PR21476 (sanitizer_common not building on AArch64 with <=3.15 kernels)

David Abdurachmanov david.abdurachmanov at gmail.com
Tue Jan 6 07:25:29 PST 2015


Hi eugenis,

A fix for PR21476 is currently in compiler-rt as r223925 / 429de66ac351c8b1e9a1bdd9da4d2fe78c14df05

The same issue is breaking GCC trunk on AArch64 systems. `__kernel_old_uid_t` is not intended to be used in native 64-bit tasks. It's only used by compat (32-bit) applications running on 64-bit kernel (multi-lib setup).

From Will Deacon (ARM):
```
AArch64 tasks only have 32-bit UIDs, so the getuid syscall (174) operates
only on 32-bit UIDs. I don't think glibc exposes a 16-bit wrapper, so I
can't see the old_uid_t being used for native applications.
```

There are a number of syscalls with "16" suffix. Those are only applicable for 32-bit tasks. In ARMv8 case, it must be running in AArch32 mode. AArch64 (LP64 and ILP32) tasks will not use them (confirmed by Andrew Pinski (Cavium)). ILP32 will use standard syscalls.

All syscalls with "16" suffix are available if kernel is configured with `CONFIG_COMPAT`, which then enables `CONFIG_HAVE_UID16`.

To summarize, only 32-bit sanitizer needs to have those as 64-bit tasks don't use them.

I only tested it with GCC trunk on 3.12.0 kernel, and in QEMU (user-mode) with 3.17.0 headers. Will test build with Clang also.

http://reviews.llvm.org/D6854

Files:
  lib/sanitizer_common/sanitizer_common_syscalls.inc
  lib/sanitizer_common/sanitizer_platform_limits_posix.cc

Index: lib/sanitizer_common/sanitizer_common_syscalls.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -1443,6 +1443,12 @@
 
 POST_SYSCALL(fchown)(long res, long fd, long user, long group) {}
 
+// Syscalls below are only available on 64-bit target if CONFIG_COMPAT
+// (which enables CONFIG_HAVE_UID16) is selected in kernel defconfig.
+// These syscalls implementations are needed for 32-bit (compat)
+// applications on 64-bit target. They will not be used by 64-bit
+// applications.
+#if SANITIZER_WORDSIZE == 32
 PRE_SYSCALL(chown16)(const void *filename, long user, long group) {
   if (filename)
     PRE_READ(filename,
@@ -1552,6 +1558,7 @@
 PRE_SYSCALL(getegid16)() {}
 
 POST_SYSCALL(getegid16)(long res) {}
+#endif // SANITIZER_WORDSIZE == 32
 
 PRE_SYSCALL(utime)(void *filename, void *times) {}
 
Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -1006,7 +1006,7 @@
 CHECK_TYPE_SIZE(__kernel_uid_t);
 CHECK_TYPE_SIZE(__kernel_gid_t);
 
-#if !defined(__aarch64__)
+#if SANITIZER_WORDSIZE == 32
 CHECK_TYPE_SIZE(__kernel_old_uid_t);
 CHECK_TYPE_SIZE(__kernel_old_gid_t);
 #endif

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6854.17831.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150106/3e3872ad/attachment.bin>


More information about the llvm-commits mailing list