Make #GP exceptions caused by out-of-bounds KASAN shadow accesses easier to understand by computing the address of the original access and printing that. More details are in the comments in the patch. This turns an error like this: kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault, probably for non-canonical address 0xe017577ddf75b7dd: 0000 [#1] PREEMPT SMP KASAN PTI into this: general protection fault, probably for non-canonical address 0xe017577ddf75b7dd: 0000 [#1] PREEMPT SMP KASAN PTI KASAN: maybe wild-memory-access in range [0x00badbeefbadbee8-0x00badbeefbadbeef] The hook is placed in architecture-independent code, but is currently only wired up to the X86 exception handler because I'm not sufficiently familiar with the address space layout and exception handling mechanisms on other architectures.
Showing the changes to include/linux (1 of 4 files). Show all
Unified · Split
| @@ -228,4 +228,10 @@ static inline void kasan_release_vmalloc(unsigned long start, · 227 unmodified lines | ||
| 228 | 228 | unsigned long free_region_end) {} |
| 229 | 229 | #endif |
| 230 | 230 | |
| 231 | +#ifdef CONFIG_KASAN_INLINE | |
| 232 | +void kasan_non_canonical_hook(unsigned long addr); | |
| 233 | +#else /* CONFIG_KASAN_INLINE */ | |
| 234 | +static inline void kasan_non_canonical_hook(unsigned long addr) { } | |
| 235 | +#endif /* CONFIG_KASAN_INLINE */ | |
| 236 | + | |
| 231 | 237 | #endif /* LINUX_KASAN_H */ |