Hi!
From: Vincenzo Frascino vincenzo.frascino@arm.com
[ Upstream commit 49c6631d3b4f61a7b5bb0453a885a12bfa06ffd8 ]
Patch series "kasan: Fix metadata detection for KASAN_HW_TAGS", v5.
With the introduction of KASAN_HW_TAGS, kasan_report() currently assumes that every location in memory has valid metadata associated. This is due to the fact that addr_has_metadata() returns always true.
As a consequence of this, an invalid address (e.g. NULL pointer address) passed to kasan_report() when KASAN_HW_TAGS is enabled, leads to a kernel panic.
...
This patch (of 2):
With the introduction of KASAN_HW_TAGS, kasan_report() accesses the metadata only when addr_has_metadata() succeeds.
Add a comment to make sure that the preconditions to the function are explicitly clarified.
As the other patch from the series is not applied, I don't believe we need this in stable. Changelog does not make any sense with just comment change cherry-picked...
Best regards, Pavel
+++ b/include/linux/kasan.h @@ -196,6 +196,13 @@ void kasan_init_tags(void); void *kasan_reset_tag(const void *addr); +/**
- kasan_report - print a report about a bad memory access detected by KASAN
- @addr: address of the bad access
- @size: size of the bad access
- @is_write: whether the bad access is a write or a read
- @ip: instruction pointer for the accessibility check or the bad access itself
- */
bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip);