*/
void kasan_non_canonical_hook(unsigned long addr)
{
- unsigned long orig_addr;
+ unsigned long orig_addr, user_orig_addr;
const char *bug_type;
/*
orig_addr = (unsigned long)kasan_shadow_to_mem((void *)addr);
+ /* Strip pointer tag before comparing against userspace ranges */
+ user_orig_addr = (unsigned long)set_tag((void *)orig_addr, 0);
+
/*
* For faults near the shadow address for NULL, we can be fairly certain
* that this is a KASAN shadow memory access.
* address, but make it clear that this is not necessarily what's
* actually going on.
*/
- if (orig_addr < PAGE_SIZE)
+ if (user_orig_addr < PAGE_SIZE) {
bug_type = "null-ptr-deref";
- else if (orig_addr < TASK_SIZE)
+ orig_addr = user_orig_addr;
+ } else if (user_orig_addr < TASK_SIZE) {
bug_type = "probably user-memory-access";
- else if (addr_in_shadow((void *)addr))
+ orig_addr = user_orig_addr;
+ } else if (addr_in_shadow((void *)addr))
bug_type = "probably wild-memory-access";
else
bug_type = "maybe wild-memory-access";