[compiler-rt] [sanitizer] Remove usage of termios ioctl constants on Linux (PR #149140)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 17 09:53:04 PDT 2025


================
@@ -482,4 +482,26 @@
 #  define SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL 0
 #endif
 
+#if SANITIZER_LINUX
+#  if !SANITIZER_GLIBC || SANITIZER_PPC
+// Workaround for
+// glibc/commit/3d3572f59059e2b19b8541ea648a6172136ec42e
+// Linux: Keep termios ioctl constants strictly internal
+#    define SANITIZER_TERMIOS_IOCTL_CONSTANTS 1
+#    if SANITIZER_GLIBC && SANITIZER_PPC
+#      define SANITIZER_TCGETS 0x402c7413
+#      define SANITIZER_TCSETS 0x802c7414
+#      define SANITIZER_TCSETSF 0x802c7415
+#      define SANITIZER_TCSETSW 0x802c7416
----------------
thurstond wrote:

I don't think we should be hardcoding `SANITIZER_TCGETS 0x402c7413` etc., because it's not portable. Besides, the aim of the sanitizers is not to expose or replace functionality that glibc does not; we only need to intercept whatever functionality glibc provides.

Let's revisit the `#ifdef TCGETS` approach. It does add a macro to sanitizer_platform.h, but so does the current patch (SANITIZER_TERMIOS_IOCTL_CONSTANTS), so it's not worse in that respect. It's cleaner that checking for SANITIZER_LINUX etc., because it directly checks the root cause, which is whether TCGETS is exported or not.


https://github.com/llvm/llvm-project/pull/149140


More information about the llvm-commits mailing list