From: Shakeel Butt <shakeel.butt@linux.dev>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org,
surenb@google.com,
syzbot+4e70c8e0a2017b432f7a@syzkaller.appspotmail.com
Subject: Re: [PATCH v2 mm-stable] procfs: avoid fetching build ID while holding VMA lock
Date: Thu, 29 Jan 2026 20:40:51 -0800 [thread overview]
Message-ID: <CAGj-7pXkzS1sioE9t_wXZK=w0O-FDK3k4n6oEsruhnc1X_0=rQ@mail.gmail.com> (raw)
In-Reply-To: <20260129215340.3742283-1-andrii@kernel.org>
On Thu, Jan 29, 2026 at 1:53 PM Andrii Nakryiko <andrii@kernel.org> wrote:
>
> Fix PROCMAP_QUERY to fetch optional build ID only after dropping mmap_lock or
> per-VMA lock, whichever was used to lock VMA under question, to avoid deadlock
> reported by syzbot:
>
> -> #1 (&mm->mmap_lock){++++}-{4:4}:
> __might_fault+0xed/0x170
> _copy_to_iter+0x118/0x1720
> copy_page_to_iter+0x12d/0x1e0
> filemap_read+0x720/0x10a0
> blkdev_read_iter+0x2b5/0x4e0
> vfs_read+0x7f4/0xae0
> ksys_read+0x12a/0x250
> do_syscall_64+0xcb/0xf80
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> -> #0 (&sb->s_type->i_mutex_key#8){++++}-{4:4}:
> __lock_acquire+0x1509/0x26d0
> lock_acquire+0x185/0x340
> down_read+0x98/0x490
> blkdev_read_iter+0x2a7/0x4e0
> __kernel_read+0x39a/0xa90
> freader_fetch+0x1d5/0xa80
> __build_id_parse.isra.0+0xea/0x6a0
> do_procmap_query+0xd75/0x1050
> procfs_procmap_ioctl+0x7a/0xb0
> __x64_sys_ioctl+0x18e/0x210
> do_syscall_64+0xcb/0xf80
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> other info that might help us debug this:
>
> Possible unsafe locking scenario:
>
> CPU0 CPU1
> ---- ----
> rlock(&mm->mmap_lock);
> lock(&sb->s_type->i_mutex_key#8);
> lock(&mm->mmap_lock);
> rlock(&sb->s_type->i_mutex_key#8);
>
> *** DEADLOCK ***
>
> To make this safe, we need to grab file refcount while VMA is still locked, but
> other than that everything is pretty straightforward. Internal build_id_parse()
> API assumes VMA is passed, but it only needs the underlying file reference, so
> just add another variant build_id_parse_file() that expects file passed
> directly.
>
> Fixes: ed5d583a88a9 ("fs/procfs: implement efficient VMA querying API for /proc/<pid>/maps")
> Reported-by: syzbot+4e70c8e0a2017b432f7a@syzkaller.appspotmail.com
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> Tested-by: Suren Baghdasaryan <surenb@google.com>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
next prev parent reply other threads:[~2026-01-30 4:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 21:53 Andrii Nakryiko
2026-01-30 3:54 ` kernel test robot
2026-01-30 20:11 ` Andrii Nakryiko
2026-01-30 20:42 ` Andrew Morton
2026-01-30 20:47 ` Andrii Nakryiko
2026-01-30 4:40 ` Shakeel Butt [this message]
2026-01-30 6:43 ` kernel test robot
2026-02-10 18:41 ` [BUG] " Thomas Gleixner
2026-02-10 19:04 ` Andrii Nakryiko
2026-02-10 21:05 ` [PATCH] procfs: Prevent double mmput() in do_procmap_query() Thomas Gleixner
2026-02-11 11:58 ` Sebastian Andrzej Siewior
2026-02-11 17:24 ` Andrii Nakryiko
2026-02-11 17:29 ` Sebastian Andrzej Siewior
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='CAGj-7pXkzS1sioE9t_wXZK=w0O-FDK3k4n6oEsruhnc1X_0=rQ@mail.gmail.com' \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=surenb@google.com \
--cc=syzbot+4e70c8e0a2017b432f7a@syzkaller.appspotmail.com \
/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