From: Markus Rankl via B4 Relay <devnull+markus.rankl.mesutronic.de@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>
Cc: "Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Markus Rankl <markus.rankl@mesutronic.de>
Subject: [PATCH] module/decompress: fix kunmap_local() address in gzip path
Date: Sun, 29 Nov 2026 19:26:49 +0100 [thread overview]
Message-ID: <20261129-module-decompress-fix-v1-1-c05da174f5fe@mesutronic.de> (raw)
From: Markus Rankl <markus.rankl@mesutronic.de>
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@vger.kernel.org
Signed-off-by: Markus Rankl <markus.rankl@mesutronic.de>
---
kernel/module/decompress.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
index cce098671be97513e67c64bc38f0f72c6e790e11..67894a78ccf60c0ae53ea05c883f0ceede413c6d 100644
--- a/kernel/module/decompress.c
+++ b/kernel/module/decompress.c
@@ -113,16 +113,18 @@ static ssize_t module_gzip_decompress(struct load_info *info,
do {
struct page *page = module_get_next_page(info);
+ void *dst;
if (IS_ERR(page)) {
retval = PTR_ERR(page);
goto out_inflate_end;
}
- s.next_out = kmap_local_page(page);
+ dst = kmap_local_page(page);
+ s.next_out = dst;
s.avail_out = PAGE_SIZE;
rc = zlib_inflate(&s, 0);
- kunmap_local(s.next_out);
+ kunmap_local(dst);
new_size += PAGE_SIZE - s.avail_out;
} while (rc == Z_OK);
---
base-commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046
change-id: 20261129-module-decompress-fix-4e215829b31e
Best regards,
--
Markus Rankl <markus.rankl@mesutronic.de>
reply other threads:[~2026-11-29 18:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129-module-decompress-fix-v1-1-c05da174f5fe@mesutronic.de \
--to=devnull+markus.rankl.mesutronic.de@kernel.org \
--cc=atomlin@atomlin.com \
--cc=da.gomez@kernel.org \
--cc=fabio.m.de.francesco@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=markus.rankl@mesutronic.de \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®