summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorDima Koziuk <dmytrokoziuk68@gmail.com>2026-10-02 23:05:08 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-10-08 23:06:24 -0700
commitb3049e4b2fa1ffbf7be642f12397c8da067f2533 (patch)
tree510bcda9b15d72f4a3f8ebb8380158455aba2996 /tools/lib/python
parentf407a2401464997329b85bd4b4242600a2f9a953 (diff)
downloadlinux-next-b3049e4b2fa1ffbf7be642f12397c8da067f2533.tar.gz
linux-next-b3049e4b2fa1ffbf7be642f12397c8da067f2533.zip
mm: kmsan: fix ioremap error cleanup
Looking further at kmsan_ioremap_page_range(), I found three cases where error cleanup leaks metadata blocks. 1. If the first iteration fails, clean is zero and cleanup is skipped, leaking any allocations that succeeded in that iteration. 2. If shadow mapping succeeds but origin mapping fails, the shadow pointer has already been cleared. Removing its mapping loses the backing block. 3. On failures after completed iterations, cleanup removes the earlier metadata mappings without freeing their backing blocks. The cleanup needed here is the same as for iounmap, so it makes sense to reuse kmsan_iounmap_pages(). Track the end of installed mappings with mapped_end and advance it after each successful shadow mapping. This includes the current shadow block if origin mapping subsequently fails, while the helper skips the missing origin mapping. Run cleanup whenever err is non-zero. Free allocations that have not been mapped directly, and use the shared helper to unmap and free the installed metadata, including blocks from completed iterations. Link: https://lore.kernel.org/20261002200508.546-2-dmytrokoziuk68@gmail.com Fixes: fdea03e12aa2 ("mm: kmsan: handle alloc failures in kmsan_ioremap_page_range()") Signed-off-by: Dima Koziuk <dmytrokoziuk68@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Alexander Potapenko <glider@google.com> Cc: Marco Elver <elver@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions