[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <86b3f8af-299a-4ae7-b2dc-0b068046fe92@kernel.org>
Date: Tue, 30 Dec 2025 23:11:31 +0100
From: "David Hildenbrand (Red Hat)" <david@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>,
Jinchao Wang <wangjinchao600@...il.com>
Cc: Song Liu <song@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau
<martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
syzbot+e008db2ac01e282550ee@...kaller.appspotmail.com,
Axel Rasmussen <axelrasmussen@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Michal Hocko <mhocko@...nel.org>, Qi Zheng <zhengqi.arch@...edance.com>,
Shakeel Butt <shakeel.butt@...ux.dev>, Wei Xu <weixugc@...gle.com>,
Yuanchu Xie <yuanchu@...gle.com>, Omar Sandoval <osandov@...com>,
Deepanshu Kartikey <kartikey406@...il.com>
Subject: Re: [PATCH] buildid: validate page-backed file before parsing build
ID
On 12/23/25 18:29, Andrew Morton wrote:
> On Tue, 23 Dec 2025 18:32:07 +0800 Jinchao Wang <wangjinchao600@...il.com> wrote:
>
>> __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@...kaller.appspotmail.com
>> Signed-off-by: Jinchao Wang <wangjinchao600@...il.com>
>>
>> ...
>>
>> --- 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;
Just wondering, we are fine with MAP_PRIVATE files, right? I guess it's
not about the actual content in the VMA (which might be different for a
MAP_PRIVATE VMA), but only about the content of the mapped file.
LGTM, although I wonder whether some of these these checks should be
exposed as part of the read_cache_folio()/do_read_cache_folio() API.
Like, having a helper function that tells us whether we can use
do_read_cache_folio() against a given mapping+file.
--
Cheers
David
Powered by blists - more mailing lists