linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
@ 2026-02-10 19:27 Andrii Nakryiko
  2026-02-10 21:07 ` Thomas Gleixner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2026-02-10 19:27 UTC (permalink / raw)
  To: akpm, linux-mm
  Cc: linux-fsdevel, bpf, surenb, shakeel.butt, Andrii Nakryiko,
	Ruikai Peng, Thomas Gleixner, syzbot+237b5b985b78c1da9600

When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we
return with -ENAMETOOLONG error. After recent changes this condition happens
later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original
goto out is now wrong and will double-mmput() mm_struct. Fix by jumping
further to clean up only vm_file and name_buf.

Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")
Reported-by: Ruikai Peng <ruikai@pwno.io>
Reported-by: Thomas Gleixner <tglx@kernel.org>
Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 fs/proc/task_mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 26188a4ad1ab..2f55efc36816 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -780,7 +780,7 @@ static int do_procmap_query(struct mm_struct *mm, void __user *uarg)
 		} else {
 			if (karg.build_id_size < build_id_sz) {
 				err = -ENAMETOOLONG;
-				goto out;
+				goto out_file;
 			}
 			karg.build_id_size = build_id_sz;
 		}
@@ -808,6 +808,7 @@ static int do_procmap_query(struct mm_struct *mm, void __user *uarg)
 out:
 	query_vma_teardown(&lock_ctx);
 	mmput(mm);
+out_file:
 	if (vm_file)
 		fput(vm_file);
 	kfree(name_buf);
-- 
2.47.3



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
  2026-02-10 19:27 [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query() Andrii Nakryiko
@ 2026-02-10 21:07 ` Thomas Gleixner
  2026-02-10 21:30 ` Shakeel Butt
  2026-02-13 23:45 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2026-02-10 21:07 UTC (permalink / raw)
  To: Andrii Nakryiko, akpm, linux-mm
  Cc: linux-fsdevel, bpf, surenb, shakeel.butt, Andrii Nakryiko,
	Ruikai Peng, syzbot+237b5b985b78c1da9600

On Tue, Feb 10 2026 at 11:27, Andrii Nakryiko wrote:
> When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we
> return with -ENAMETOOLONG error. After recent changes this condition happens
> later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original
> goto out is now wrong and will double-mmput() mm_struct. Fix by jumping
> further to clean up only vm_file and name_buf.
>
> Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")
> Reported-by: Ruikai Peng <ruikai@pwno.io>
> Reported-by: Thomas Gleixner <tglx@kernel.org>
> Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
> Signed-off-by: Andrii Nakryiko <andrii@kernel.fs>

Tested-by: Thomas Gleixner <tglx@kernel.org>

I did not test this one, but the identical fix I did myself :)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
  2026-02-10 19:27 [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query() Andrii Nakryiko
  2026-02-10 21:07 ` Thomas Gleixner
@ 2026-02-10 21:30 ` Shakeel Butt
  2026-02-10 21:38   ` Andrii Nakryiko
  2026-02-13 23:45 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Shakeel Butt @ 2026-02-10 21:30 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: akpm, linux-mm, linux-fsdevel, bpf, surenb, Ruikai Peng,
	Thomas Gleixner, syzbot+237b5b985b78c1da9600

On Tue, Feb 10, 2026 at 11:27:38AM -0800, Andrii Nakryiko wrote:
> When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we
> return with -ENAMETOOLONG error. After recent changes this condition happens
> later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original
> goto out is now wrong and will double-mmput() mm_struct. Fix by jumping
> further to clean up only vm_file and name_buf.
> 
> Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")

Why didn't the BPF AI review bot didn't trigger for b5cbacd7f86f?

> Reported-by: Ruikai Peng <ruikai@pwno.io>
> Reported-by: Thomas Gleixner <tglx@kernel.org>
> Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
  2026-02-10 21:30 ` Shakeel Butt
@ 2026-02-10 21:38   ` Andrii Nakryiko
  0 siblings, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2026-02-10 21:38 UTC (permalink / raw)
  To: Shakeel Butt, Ihor Solodrai
  Cc: Andrii Nakryiko, akpm, linux-mm, linux-fsdevel, bpf, surenb,
	Ruikai Peng, Thomas Gleixner, syzbot+237b5b985b78c1da9600

On Tue, Feb 10, 2026 at 1:30 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> On Tue, Feb 10, 2026 at 11:27:38AM -0800, Andrii Nakryiko wrote:
> > When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we
> > return with -ENAMETOOLONG error. After recent changes this condition happens
> > later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original
> > goto out is now wrong and will double-mmput() mm_struct. Fix by jumping
> > further to clean up only vm_file and name_buf.
> >
> > Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")
>
> Why didn't the BPF AI review bot didn't trigger for b5cbacd7f86f?
>

I was wondering the same, tbh. I think it's because I marked the patch
for mm-stable tree with [PATCH mm-stable], and our BPF CI
infrastructure just ignored this patch (even though bpf mailing list
was cc'ed).

> > Reported-by: Ruikai Peng <ruikai@pwno.io>
> > Reported-by: Thomas Gleixner <tglx@kernel.org>
> > Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
> > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
>
> Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
  2026-02-10 19:27 [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query() Andrii Nakryiko
  2026-02-10 21:07 ` Thomas Gleixner
  2026-02-10 21:30 ` Shakeel Butt
@ 2026-02-13 23:45 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-13 23:45 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: akpm, linux-mm, linux-fsdevel, bpf, surenb, shakeel.butt, ruikai,
	tglx, syzbot+237b5b985b78c1da9600

Hello:

This patch was applied to bpf/bpf.git (master)
by Andrew Morton <akpm@linux-foundation.org>:

On Tue, 10 Feb 2026 11:27:38 -0800 you wrote:
> When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we
> return with -ENAMETOOLONG error. After recent changes this condition happens
> later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original
> goto out is now wrong and will double-mmput() mm_struct. Fix by jumping
> further to clean up only vm_file and name_buf.
> 
> Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")
> Reported-by: Ruikai Peng <ruikai@pwno.io>
> Reported-by: Thomas Gleixner <tglx@kernel.org>
> Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> 
> [...]

Here is the summary with links:
  - [mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query()
    https://git.kernel.org/bpf/bpf/c/61dc9f776705

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-13 23:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-10 19:27 [PATCH mm-hotfixes-stable] procfs: fix possible double mmput() in do_procmap_query() Andrii Nakryiko
2026-02-10 21:07 ` Thomas Gleixner
2026-02-10 21:30 ` Shakeel Butt
2026-02-10 21:38   ` Andrii Nakryiko
2026-02-13 23:45 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox