Re: [PATCH] module/decompress: fix kunmap_local() address in gzip path
From: Petr Pavlu
Date: Mon Nov 30 2026 - 05:41:34 EST
On 11/29/26 7:26 PM, Markus Rankl via B4 Relay wrote:
> From: Markus Rankl <markus.rankl@xxxxxxxxxxxxx>
>
> zlib_inflate() advances s.next_out past the bytes it has written, and
> module_gzip_decompress() then passes that pointer to kunmap_local().
> kunmap_local() rounds the address down to its page, so this works while
> the page is only partly filled. All pages of a module except the last
> one are filled completely, though, and s.next_out then points to the
> start of the following page.
>
> For a highmem page that address is the neighbouring kmap_local fixmap
> slot. kunmap_local_indexed() warns about the mismatch, clears the wrong
> PTE and leaves the page mapped, and a later kmap_local_page() on that
> slot hits the BUG_ON() in __kmap_local_pfn_prot(). Lowmem pages are not
> affected because kunmap_local() does nothing for them.
>
> Seen on a 32-bit ARM board (AM437x, 1 GiB RAM, CONFIG_HIGHMEM) loading
> gzip-compressed modules with CONFIG_MODULE_DECOMPRESS:
>
> WARNING: CPU: 0 PID: 224 at mm/highmem.c:623 kunmap_local_indexed+0x17c/0x184
> Call trace:
> kunmap_local_indexed from module_decompress+0x1ac/0x2d0
> module_decompress from init_module_from_file+0xc8/0xe4
> init_module_from_file from sys_finit_module+0x13c/0x304
> sys_finit_module from ret_fast_syscall+0x0/0x54
> ...
> kernel BUG at mm/highmem.c:565!
> PC is at __kmap_local_pfn_prot+0x164/0x168
>
> Unmap the address returned by kmap_local_page(), as the xz and zstd
> paths do.
>
> Fixes: 554694ba120b ("module: Replace kmap() with kmap_local_page()")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Markus Rankl <markus.rankl@xxxxxxxxxxxxx>
Looks ok to me. I've queued the patch on modules-next.
--
Thanks,
Petr