]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
procfs: fix possible double mmput() in do_procmap_query()
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 10 Feb 2026 19:27:38 +0000 (11:27 -0800)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:29 +0000 (07:21 -0500)
commit8adaff87db143583e08eec4f4e7788f1ef8af94d
tree142cfd1c3f11ded8489b12970af00f8fbb5e489c
parentf64491066c662fd3cd8b5ebcd296879ea33dfb62
procfs: fix possible double mmput() in do_procmap_query()

[ Upstream commit 61dc9f776705d6db6847c101b98fa4f0e9eb6fa3 ]

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.

Link: https://lkml.kernel.org/r/20260210192738.3041609-1-andrii@kernel.org
Fixes: b5cbacd7f86f ("procfs: avoid fetching build ID while holding VMA lock")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reported-by: Ruikai Peng <ruikai@pwno.io>
Reported-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Reported-by: syzbot+237b5b985b78c1da9600@syzkaller.appspotmail.com
Cc: Ruikai Peng <ruikai@pwno.io>
Closes: https://lkml.kernel.org/r/CAFD3drOJANTZPuyiqMdqpiRwOKnHwv5QgMNZghCDr-WxdiHvMg@mail.gmail.com
Closes: https://lore.kernel.org/all/698aaf3c.050a0220.3b3015.0088.GAE@google.com/T/#u
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/proc/task_mmu.c