[clang] [sanitizer] Allow use-after-scope front-end argument to take effect with -fsanitize=kernel-address (PR #137015)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 28 10:37:10 PDT 2025


vitalybuka wrote:

> > However, please be aware that default for Asan is ON. Should Kasan default be OFF in the beginning?
> 
> @vitalybuka I'm not sure how many users test a kernel exclusively in `-O0`, but to those who do, I suppose defaulting this to ON could allow the sanitizer to capture never-before-seen use-after-scope issues.
> 
> With that said, I'm inclined to keep this defaulted to ON like normal ASAN. Does this sound reasonable, or am I missing some negative side-effects that you had in mind when posting this comment? Would it be worth mentioning this change as a release note regardless?
> 
> EDIT: I realize one detail I missed when I wrote the description of the PR. The 'workaround' to get `use-after-scope` functioning with `-fsanitize=kernel-address` for `-O1` and up before this PR involves adding `-mllvm -asan-use-after-scope=1`. So by defaulting `-fsanitize-address-use-after-scope` to ON for `-fsanitize=kernel-address` in this PR, we'd actually be enabling UAS detection for all optimization levels which may be new to those who haven't employed the workaround. I suppose from that PoV, effects are a bit more far reaching than I initially though. I'm still inclined to keep it ON by default if not to increase coverage, but maybe I'm being optimistic that it wouldn't have negative effects elsewhere...

LGTM, I guess  it's easy to add -fno-sanitize-address-use-after-scope into kernel build files if needed.

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


More information about the cfe-commits mailing list