From: sashiko-bot@kernel.org
To: "Sanghyun Park" <sanghyun.park.cnu@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5] bpf: Fix use-after-free on mm_struct in bpf_find_vma()
Date: Tue, 30 Jun 2026 02:47:02 +0000 [thread overview]
Message-ID: <20260630024702.C111F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630023443.3026627-2-sanghyun.park.cnu@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The patch removes the `bpf_iter_mmput_async()` helper function but leaves an active call to it in `bpf_iter_task_vma_destroy()`, causing an unconditional compilation failure.
- [Low] Calling `mmput_async()` directly causes a build failure on configurations without `CONFIG_MMU` and `CONFIG_FUTEX_PRIVATE_HASH`.
--
commit 2e44c7b3855fc202fcf8df33fd8efe7bae06e921
Author: Sanghyun Park <sanghyun.park.cnu@gmail.com>
Subject: bpf: Fix use-after-free on mm_struct in bpf_find_vma()
This commit addresses a use-after-free in bpf_find_vma() by safely
pinning task->mm for foreign tasks under alloc_lock. It adds a required
mmput_async() call on the exit path and removes the static inline wrapper
bpf_iter_mmput_async().
> diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
> index e791ae065c39b..27ceead874651 100644
> --- a/kernel/bpf/task_iter.c
> +++ b/kernel/bpf/task_iter.c
[ ... ]
> @@ -782,6 +807,9 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,
> ret = 0;
> }
> bpf_mmap_unlock_mm(work, mm);
> +out:
> + if (mmput_needed)
> + mmput_async(mm);
[Severity: Low]
Does directly invoking mmput_async() break the build on configurations
without CONFIG_MMU?
The removed bpf_iter_mmput_async() wrapper previously fell back to mmput()
when CONFIG_MMU was disabled. Even though this new path is guarded by a
runtime IS_ENABLED(CONFIG_MMU) check earlier in the function, the C compiler
still evaluates the function call, which might be undeclared in the headers
on !CONFIG_MMU builds.
> return ret;
> }
>
> @@ -796,15 +824,6 @@ const struct bpf_func_proto bpf_find_vma_proto = {
> .arg5_type = ARG_ANYTHING,
> };
>
> -static inline void bpf_iter_mmput_async(struct mm_struct *mm)
> -{
> -#ifdef CONFIG_MMU
> - mmput_async(mm);
> -#else
> - mmput(mm);
> -#endif
> -}
> -
[Severity: Low]
Does the removal of bpf_iter_mmput_async() cause a build failure?
While the wrapper was removed here, it looks like it is still being called
further down in the file:
kernel/bpf/task_iter.c:bpf_iter_task_vma_destroy() {
...
if (kit->data) {
bpf_iter_task_vma_snapshot_reset(&kit->data->snapshot);
put_task_struct(kit->data->task);
bpf_iter_mmput_async(kit->data->mm);
...
}
}
Will this cause an undeclared identifier error when compiling
bpf_iter_task_vma_destroy()?
> struct bpf_iter_task_vma_kern_data {
> struct task_struct *task;
> struct mm_struct *mm;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630023443.3026627-2-sanghyun.park.cnu@gmail.com?part=1
next prev parent reply other threads:[~2026-06-30 2:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 2:34 [PATCH bpf-next v5] bpf: Fix use-after-free on mm_struct in bpf_find_vma() Sanghyun Park
2026-06-30 2:47 ` sashiko-bot [this message]
2026-06-30 9:23 ` [syzbot ci] " syzbot ci
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=20260630024702.C111F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sanghyun.park.cnu@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox