Skip to content

Commit 3ed86b9

Browse files
xairyctmarinas
authored andcommitted
kasan, arm64: fix pointer tags in KASAN reports
As of the "arm64: expose FAR_EL1 tag bits in siginfo" patch, the address that is passed to report_tag_fault has pointer tags in the format of 0x0X, while KASAN uses 0xFX format (note the difference in the top 4 bits). Fix up the pointer tag for kernel pointers in do_tag_check_fault by setting them to the same value as bit 55. Explicitly use __untagged_addr() instead of untagged_addr(), as the latter doesn't affect TTBR1 addresses. Fixes: dceec3f ("arm64: expose FAR_EL1 tag bits in siginfo") Fixes: 4291e9e ("kasan, arm64: print report from tag fault handler") Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Link: https://linux-review.googlesource.com/id/I9ced973866036d8679e8f4ae325de547eb969649 Link: https://lore.kernel.org/r/ff30b0afe6005fd046f9ac72bfb71822aedccd89.1610731872.git.andreyknvl@google.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 3a57a64 commit 3ed86b9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

arch/arm64/mm/fault.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,11 @@ static int do_tag_check_fault(unsigned long far, unsigned int esr,
709709
struct pt_regs *regs)
710710
{
711711
/*
712-
* The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN for tag
713-
* check faults. Mask them out now so that userspace doesn't see them.
712+
* The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN
713+
* for tag check faults. Set them to corresponding bits in the untagged
714+
* address.
714715
*/
715-
far &= (1UL << 60) - 1;
716+
far = (__untagged_addr(far) & ~MTE_TAG_MASK) | (far & MTE_TAG_MASK);
716717
do_bad_area(far, esr, regs);
717718
return 0;
718719
}

0 commit comments

Comments
 (0)