History

x86/kasan: Print original address on #GP

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.

Jann Horn committed 6 years ago

Commit 2f004ee1 parent aa49f204 files · +48 −21Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/kasan.h+6−0
@@ -228,4 +228,10 @@ static inline void kasan_release_vmalloc(unsigned long start, · 227 unmodified lines
228 unsigned long free_region_end) {}228 unsigned long free_region_end) {}
229#endif229#endif
230 230
231#ifdef CONFIG_KASAN_INLINE
232void kasan_non_canonical_hook(unsigned long addr);
233#else /* CONFIG_KASAN_INLINE */
234static inline void kasan_non_canonical_hook(unsigned long addr) { }
235#endif /* CONFIG_KASAN_INLINE */
236
231#endif /* LINUX_KASAN_H */237#endif /* LINUX_KASAN_H */