public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] buildid: validate page-backed file before parsing build ID
@ 2025-12-23 10:32 Jinchao Wang
  2025-12-23 17:29 ` Andrew Morton
  2025-12-23 19:05 ` Shakeel Butt
  0 siblings, 2 replies; 9+ messages in thread
From: Jinchao Wang @ 2025-12-23 10:32 UTC (permalink / raw)
  To: Andrew Morton, Song Liu, Jiri Olsa, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau,
	Eduard Zingerman, Yonghong Song, John Fastabend, KP Singh,
	Stanislav Fomichev, Hao Luo, linux-kernel, bpf
  Cc: Jinchao Wang, syzbot+e008db2ac01e282550ee

__build_id_parse() only works on page-backed storage.  Its helper paths
eventually call mapping->a_ops->read_folio(), so explicitly reject VMAs
that do not map a regular file or lack valid address_space operations.

Reported-by: syzbot+e008db2ac01e282550ee@syzkaller.appspotmail.com
Signed-off-by: Jinchao Wang <wangjinchao600@gmail.com>
---
 lib/buildid.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/buildid.c b/lib/buildid.c
index aaf61dfc0919..7131594cb071 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -280,7 +280,10 @@ static int __build_id_parse(struct vm_area_struct *vma, unsigned char *build_id,
 	int ret;
 
 	/* only works for page backed storage  */
-	if (!vma->vm_file)
+	if (!vma->vm_file ||
+	    !S_ISREG(file_inode(vma->vm_file)->i_mode) ||
+	    !vma->vm_file->f_mapping->a_ops ||
+	    !vma->vm_file->f_mapping->a_ops->read_folio)
 		return -EINVAL;
 
 	freader_init_from_file(&r, buf, sizeof(buf), vma->vm_file, may_fault);
-- 
2.43.0


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

end of thread, other threads:[~2026-01-11 11:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 10:32 [PATCH] buildid: validate page-backed file before parsing build ID Jinchao Wang
2025-12-23 17:29 ` Andrew Morton
2025-12-30 22:11   ` David Hildenbrand (Red Hat)
2026-01-05 22:52     ` Andrii Nakryiko
2026-01-06 19:16       ` David Hildenbrand (Red Hat)
2026-01-09 23:43         ` Andrii Nakryiko
2026-01-11 11:32           ` David Hildenbrand (Red Hat)
2025-12-23 19:05 ` Shakeel Butt
2025-12-24  3:29   ` Jinchao Wang

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