[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240801124220.GP5334@ZenIV>
Date: Thu, 1 Aug 2024 13:42:20 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Lizhi Xu <lizhi.xu@...driver.com>
Cc: brauner@...nel.org, jack@...e.cz, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, phillip@...ashfs.org.uk,
squashfs-devel@...ts.sourceforge.net,
syzbot+24ac24ff58dc5b0d26b9@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH] filemap: Init the newly allocated folio memory to 0 for
the filemap
On Thu, Aug 01, 2024 at 04:12:24PM +0800, Lizhi Xu wrote:
> > * ->read_folio() had been called, claimed to have succeeded and
> > yet it had left something in range 0..inode->i_size-1 uninitialized.
> > Again, a bug, this time in ->read_folio() instance.
> read_folio, have you noticed that the file value was passed to read_folio is NULL?
> fs/namei.c
> const char *page_get_link(struct dentry *dentry, struct inode *inode
> ...
> 5272 read_mapping_page(mapping, 0, NULL);
>
> So, Therefore, no matter what, the value of folio will not be initialized by file
> in read_folio.
What does struct file have to do with anything? What it asks is the
first page of the address space of inode in question.
file argument of ->read_folio() is not how an instance determines which
filesystem object it's dealing with. _That_ is determined by the
address space (mapping) the folio had been attached to. For some
filesystems that is not enough - they need an information established
at open() time. Those ->read_folio() instances can pick such stuff
from the file argument - and those obviously cannot be used with
page_get_link(), since for symlinks there's no opened files, etc.
Most of the instances do not use the 'file' argument. In particular,
squashfs_symlink_read_folio() doesn't even look at it.
It would probably be less confusing if the arguments of ->read_folio()
went in the opposite order, but that's a separate story. In any case,
"which filesystem object" is determined by folio->mapping, "which
offset in that filesystem object" comes from folio_pos(folio), not
that it realistically could be anything other than 0 in case of a symlink
(they can't be more than 4Kb long, so the first page will cover the
entire thing).
Powered by blists - more mailing lists