1 From 9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 Mon Sep 17 00:00:00 2001
2 From: Fangrui Song <i@maskray.me>
3 Date: Mon, 11 Jul 2022 12:53:34 -0700
4 Subject: [PATCH] [sanitizer] Remove #include <linux/fs.h> to resolve
5 fsconfig_command/mount_attr conflict with glibc 2.36
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 It is generally not a good idea to mix usage of glibc headers and Linux UAPI
11 headers (https://sourceware.org/glibc/wiki/Synchronizing_Headers). In glibc
12 since 7eae6a91e9b1670330c9f15730082c91c0b1d570 (milestone: 2.36), sys/mount.h
13 defines `fsconfig_command` which conflicts with linux/mount.h:
15 .../usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’
17 Remove #include <linux/fs.h> which pulls in linux/mount.h. Expand its 4 macros manually.
18 Android sys/mount.h doesn't define BLKBSZGET and it still needs linux/fs.h.
19 In the long term we should move Linux specific definitions to sanitizer_platform_limits_linux.cpp
20 but this commit is easy to cherry pick into older compiler-rt releases.
22 Fix https://github.com/llvm/llvm-project/issues/56421
24 Reviewed By: #sanitizers, vitalybuka, zatrazz
26 Differential Revision: https://reviews.llvm.org/D129471
28 .../sanitizer_platform_limits_posix.cpp | 10 ++++++----
29 1 file changed, 6 insertions(+), 4 deletions(-)
31 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
32 index 4bd425435d56..3a94b260686f 100644
33 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
34 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
37 #include <linux/cdrom.h>
39 +#if SANITIZER_ANDROID
42 #include <linux/hdreg.h>
43 #include <linux/input.h>
44 #include <linux/ioctl.h>
45 @@ -876,10 +878,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
46 unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
47 unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
49 - unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
50 - unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
51 - unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
52 - unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
53 + unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
54 + unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
55 + unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
56 + unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
57 unsigned IOCTL_GIO_CMAP = GIO_CMAP;
58 unsigned IOCTL_GIO_FONT = GIO_FONT;
59 unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;