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

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 10:54:21 PDT 2025


================
@@ -482,4 +482,17 @@
 #  define SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL 0
 #endif
 
+#if SANITIZER_LINUX
+#    if SANITIZER_GLIBC
+// Workaround for
+// glibc/commit/3d3572f59059e2b19b8541ea648a6172136ec42e
+// Linux: Keep termios ioctl constants strictly internal
+#      if __GLIBC_PREREQ(2, 41)
+#        define SANITIZER_TERMIOS_IOCTL_CONSTANTS 0
+#      else
+#        define SANITIZER_TERMIOS_IOCTL_CONSTANTS 1
+#      endif
+#    else
+#      define SANITIZER_TERMIOS_IOCTL_CONSTANTS 1
+#    endif
----------------
thurstond wrote:

The sanitizers need the interceptors to know that the struct has been written to to avoid false positives in subsequent checks e.g.,

```
struct termios tio; // Uninitialized
ioctl(fd, TCGETS, &tio);
printf("output baud rate: %u\n", tio.c_ospeed); // MemorySanitizer would have a false positive here because it doesn't know that the ioctl initialized tio
```

(since the interceptor is in sanitizer_common, it is also used in AddressSanitizer and ThreadSanitizer. I believe omitting it may result in false positives for ThreadSanitizer as well.)

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


More information about the llvm-commits mailing list