From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] uprobes: Use flexible array for xol_area bitmap
Date: Mon, 11 May 2026 22:34:27 +0000 [thread overview]
Message-ID: <20260511223428.7064FC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260510214118.41926-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Calling kfree() on a flexible array member triggers an invalid free, leading to kernel panic or slab corruption.
--
commit 2653ad1e88bfeb53b361b9c646fc5e888019afa9
Author: Rosen Penev <rosenp@gmail.com>
uprobes: Use flexible array for xol_area bitmap
This commit converts the xol_area bitmap from a separately allocated
pointer to a flexible array member. It also updates the allocation to
use kzalloc_flex() and removes the associated error handling in
__create_xol_area().
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 4084e926e2844..9ef74c2ad3907 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -108,7 +108,6 @@ static LIST_HEAD(delayed_uprobe_list);
> */
> struct xol_area {
> wait_queue_head_t wq; /* if all slots are busy */
> - unsigned long *bitmap; /* 0 = free slot */
>
> struct page *page;
> /*
> @@ -117,6 +116,7 @@ struct xol_area {
> * the vma go away, and we must handle that reasonably gracefully.
> */
> unsigned long vaddr; /* Page(s) of instruction slots */
> + unsigned long bitmap[]; /* 0 = free slot */
> };
Does this conversion leave a stale kfree() in uprobe_clear_state()?
Since bitmap is now a flexible array member, area->bitmap evaluates to an
interior address within the xol_area slab object.
Looking at uprobe_clear_state(), the kfree() is still present:
kernel/events/uprobes.c:uprobe_clear_state() {
...
if (!area)
return;
put_page(area->page);
kfree(area->bitmap);
kfree(area);
}
Could this lead to slab corruption or a kernel panic when a process with a
registered uprobe is terminated, since we are passing an interior pointer to
kfree()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260510214118.41926-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-05-11 22:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 21:41 [PATCH] uprobes: Use flexible array for xol_area bitmap Rosen Penev
2026-05-11 4:33 ` Masami Hiramatsu
2026-05-11 22:34 ` sashiko-bot [this message]
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=20260511223428.7064FC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox