From: Miklos Szeredi <miklos@szeredi.hu>
To: Chengguang Xu <cgxu519@139.com>
Cc: Huang Jianan <huangjianan@oppo.com>,
overlayfs <linux-unionfs@vger.kernel.org>,
linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org,
guoweichao@oppo.com, yh@oppo.com, zhangshiming@oppo.com,
guanyuwei@oppo.com, jnhuang95@gmail.com,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Chengguang Xu <cgxu519@mykernel.net>
Subject: Re: [PATCH v3] ovl: fix null pointer when filesystemdoesn'tsupportdirect IO
Date: Wed, 22 Sep 2021 16:00:47 +0200 [thread overview]
Message-ID: <CAJfpegs_T5BQ+e79T=1fqTScjfaOyAftykmzK6=hdS=WhVvWsg@mail.gmail.com> (raw)
In-Reply-To: <314324e7-02d7-dc43-b270-fb8117953549@139.com>
On Wed, 22 Sept 2021 at 15:21, Chengguang Xu <cgxu519@139.com> wrote:
>
> 在 2021/9/22 16:24, Huang Jianan 写道:
> >
> >
> > 在 2021/9/22 16:06, Chengguang Xu 写道:
> >> 在 2021/9/22 15:23, Huang Jianan 写道:
> >>> From: Huang Jianan <huangjianan@oppo.com>
> >>>
> >>> At present, overlayfs provides overlayfs inode to users. Overlayfs
> >>> inode provides ovl_aops with noop_direct_IO to avoid open failure
> >>> with O_DIRECT. But some compressed filesystems, such as erofs and
> >>> squashfs, don't support direct_IO.
> >>>
> >>> Users who use f_mapping->a_ops->direct_IO to check O_DIRECT support,
> >>> will read file through this way. This will cause overlayfs to access
> >>> a non-existent direct_IO function and cause panic due to null pointer:
> >>
> >> I just looked around the code more closely, in open_with_fake_path(),
> >>
> >> do_dentry_open() has already checked O_DIRECT open flag and
> >> a_ops->direct_IO of underlying real address_space.
> >>
> >> Am I missing something?
> >>
> >>
> >
> > It seems that loop_update_dio will set lo->use_dio after open file
> > without set O_DIRECT.
> > loop_update_dio will check f_mapping->a_ops->direct_IO but it deal
> > with ovl_aops with
> > noop _direct_IO.
> >
> > So I think we still need a new aops?
>
>
> It means we should only set ->direct_IO for overlayfs inodes whose
> underlying fs has DIRECT IO ability.
First let's fix the oops: ovl_read_iter()/ovl_write_iter() must check
real file's ->direct_IO if IOCB_DIRECT is set in iocb->ki_flags and
return -EINVAL if not.
To fix the loop -> overlay -> squashfs case your suggestion of having
separate aops depending on the real inode's ->direct_IO sounds good.
Thanks,
Miklos
next prev parent reply other threads:[~2021-09-22 14:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-18 12:13 [PATCH] ovl: fix null pointer when filesystem doesn't support direct IO Huang Jianan
2021-09-22 1:56 ` Chengguang Xu
2021-09-22 3:39 ` Huang Jianan
2021-09-22 3:47 ` [PATCH v2] " Huang Jianan
2021-09-22 5:09 ` Chengguang Xu
2021-09-22 7:18 ` Huang Jianan
2021-09-22 7:23 ` [PATCH v3] " Huang Jianan
2021-09-22 8:06 ` Chengguang Xu
2021-09-22 8:24 ` Huang Jianan
2021-09-22 13:20 ` [PATCH v3] ovl: fix null pointer when filesystemdoesn'tsupportdirect IO Chengguang Xu
2021-09-22 14:00 ` Miklos Szeredi [this message]
2021-09-27 9:38 ` Miklos Szeredi
2021-09-28 7:01 ` Huang Jianan
2021-09-28 7:17 ` Miklos Szeredi
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='CAJfpegs_T5BQ+e79T=1fqTScjfaOyAftykmzK6=hdS=WhVvWsg@mail.gmail.com' \
--to=miklos@szeredi.hu \
--cc=cgxu519@139.com \
--cc=cgxu519@mykernel.net \
--cc=chao@kernel.org \
--cc=guanyuwei@oppo.com \
--cc=guoweichao@oppo.com \
--cc=huangjianan@oppo.com \
--cc=jnhuang95@gmail.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=yh@oppo.com \
--cc=zhangshiming@oppo.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;
as well as URLs for NNTP newsgroup(s).