[compiler-rt] [asan] Add readability guard for %s in printf interceptor (PR #176711)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 07:02:01 PST 2026


================
@@ -551,6 +551,12 @@ static void printf_common(void *ctx, const char *format, va_list aq) {
       continue;
     } else if (size == FSS_STRLEN) {
       if (void *argp = va_arg(aq, void *)) {
+        // Check whether the first byte of the %s argument is readable.
+        if (!IsAccessibleMemoryRange((uptr)argp, 1)) {
----------------
vitalybuka wrote:

usually we consider SEGV a good readable crash
The goal of sanitizers to detect memory accesses to mapped which will not result in SEGV, we have COMMON_INTERCEPTOR_READ_RANGE for that.

There are many cases where we can add such checks, but likely SEGV will have more info for debugging, including registers.

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


More information about the llvm-commits mailing list