From: sashiko-bot@kernel.org
To: "Hao Ge" <hao.ge@linux.dev>
Cc: linux-modules@vger.kernel.org
Subject: Re: [PATCH v9 2/4] alloc_tag: clean up the populate failure path
Date: Tue, 08 Sep 2026 09:38:45 +0000 [thread overview]
Message-ID: <20260908093845.9F0BC1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908092412.115953-3-hao.ge@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The return value of kasan_alloc_module_shadow() is ignored in vm_module_tags_populate(), which can lead to a kernel panic if shadow memory allocation fails.
--
commit 2ae06d89a64873006e3ba06f14d9b47ec2d37bcf
Author: Hao Ge <hao.ge@linux.dev>
alloc_tag: clean up the populate failure path
The reservation is already stored in the maple tree when
vm_module_tags_populate() fails. A failed load never unloads the
module, so nothing releases the entry. Release it and roll
module_tags.size back.
> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
> index 2070e682fe106..95ddf5b743d0b 100644
> --- a/mm/alloc_tag.c
> +++ b/mm/alloc_tag.c
> @@ -804,6 +804,13 @@ static int vm_module_tags_populate(void)
> next_page, PAGE_SHIFT) < 0) {
> release_pages_arg arg = { .pages = next_page };
>
> + /*
> + * vmap_pages_range() only runs once all pages were
> + * allocated, and it may have installed some mappings
> + * before failing. Undo them.
> + */
> + if (nr == more_pages)
> + vunmap_range(phys_end, phys_end + (nr << PAGE_SHIFT));
> /* Clean up and error out */
> release_pages(arg, nr);
> return -ENOMEM;
> }
[Severity: High]
This isn't a bug introduced by this patch, but just below this code in
vm_module_tags_populate(), the return value of kasan_alloc_module_shadow() is
ignored:
if (old_shadow_end < new_shadow_end)
kasan_alloc_module_shadow((void *)old_shadow_end,
new_shadow_end - old_shadow_end,
GFP_KERNEL);
If the shadow memory allocation fails due to memory pressure, could this lead
to a kernel panic?
When the module later accesses its allocation tags, the KASAN instrumentation
would attempt to read unmapped shadow memory, causing a fatal page fault.
Since other kernel components like mm/execmem.c explicitly check the return
value of this function, should vm_module_tags_populate() also check for
allocation failure and error out appropriately?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908092412.115953-1-hao.ge@linux.dev?part=2
next prev parent reply other threads:[~2026-09-08 9:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 9:24 [PATCH v9 0/4] alloc_tag and module codetag section fixes Hao Ge
2026-09-08 9:24 ` [PATCH v9 1/4] alloc_tag: move release_module_tags() above reserve_module_tags() Hao Ge
2026-09-08 9:24 ` [PATCH v9 2/4] alloc_tag: clean up the populate failure path Hao Ge
2026-09-08 9:38 ` sashiko-bot [this message]
2026-09-08 9:24 ` [PATCH v9 3/4] module: introduce SH_ENTSIZE_STANDALONE for separately allocated sections Hao Ge
2026-09-09 11:30 ` Petr Pavlu
2026-09-09 12:47 ` Hao Ge
2026-09-09 13:08 ` Hao Ge
2026-09-09 13:57 ` Petr Pavlu
2026-09-08 9:24 ` [PATCH v9 4/4] module: allocate codetag sections before the regular module layout Hao Ge
2026-09-08 9:47 ` sashiko-bot
2026-09-09 11:47 ` Petr Pavlu
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=20260908093845.9F0BC1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hao.ge@linux.dev \
--cc=linux-modules@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.