From: Vivek Goyal <vgoyal@redhat.com>
To: Liu Bo <bo.liu@linux.alibaba.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH] Virtiofs: fix null pointer deference in directIO
Date: Thu, 18 Jul 2019 16:51:10 -0400 [thread overview]
Message-ID: <20190718205110.GB30636@redhat.com> (raw)
In-Reply-To: <20190718185800.yu24umzaajo42aft@US-160370MP2.local>
On Thu, Jul 18, 2019 at 11:58:01AM -0700, Liu Bo wrote:
> On Thu, Jul 18, 2019 at 02:18:39PM -0400, Vivek Goyal wrote:
> > On Fri, Jul 12, 2019 at 06:35:42AM +0800, Liu Bo wrote:
> > > Virtiofs has used memremap to create page structs for its managed memory
> > > and set pagemap's type to MEMORY_DEVICE_FS_DAX. Thus, the page from
> > > virtiofs's managed memory is a ZONE_DEVICE page, if %devmap_managed_key
> > > was enabled by pmem drivers, put_page() will run into
> > > __put_devmap_managed_page(). However, as page_free ops is not defined, it
> > > ends up with a NULL pointer dereference.
> > >
> > > As virtiofs presents its managed memory range as a dax device, this patch
> > > makes virtiofs mimic how nvdimm/pmem.c setups pagemap fsdax.
> > >
> > > =================
> > >
> > > [ 1223.732964] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
> > > [ 1223.733043] PGD 800000026bd91067 P4D 800000026bd91067 PUD 27631e067 PMD 0
> > > [ 1223.733085] Oops: 0010 [#1] SMP PTI
> > > [ 1223.733114] CPU: 1 PID: 16505 Comm: build Not tainted 4.19.48-dff9509 #1
> > > [ 1223.733157] RIP: 0010: (null)
> > > [ 1223.733179] Code: Bad RIP value.
> > > ..
> > > [ 1223.733671] Call Trace:
> > > [ 1223.733704] fuse_release_user_pages+0xad/0xb0
> > > [ 1223.733751] fuse_direct_io+0x3ec/0x6a0
> > > [ 1223.733823] fuse_dax_direct_write+0x3c/0x70
> > > [ 1223.733863] fuse_file_write_iter+0x2ea/0x4c0
> > > [ 1223.733978] __vfs_write+0xde/0x160
> > > [ 1223.734009] vfs_write+0xab/0x190
> > > [ 1223.734061] ksys_write+0x45/0xc0
> > > [ 1223.734094] do_syscall_64+0x6b/0x330
> > > [ 1223.734214] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > > [ 1223.734261] RIP: 0033:0x15536bcddfd0
> > >
> > > The reproducer could be as simply as,
> > >
> > > addr = mmap(..., fileA, ...);
> > > fdB = open(fileB, O_DIRECT);
> > > write(fdB, addr);
> > >
> > > Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
> >
> > I am looking at this now and trying to understand it better. One problem
> > I see is with page pinning. If a page is pinned, how do we make sure it
> > is not evicted by reclaim logic. IIUC, right now memory range relciam
> > logic is not aware about page pinning.
> >
> > For instance, in above example, write(fdB, addr) will pin pages in fileA.
> > While write is going on we need to make sure dax memory ranges covering
> > those pages are not reclaimed.
>
> Good question, it is indeed a problem, i_mmap_sem is not held by page
> pinning so that dax range reclaim is free to go, nor page pinning in
> within iomap_begin() and iomap_end() pair.
>
> While that is a problem, this patch is fixing a different one because
> of the lack of ->page_free definition.
Sure, but in the definition of ->page_free, you are calling
"wake_up_var(page->_refcount)". This will make sense only if somebody
is waiting on this.
I am checking xfs code and it seems to be waiting for this. We probably
will have to modify virtio-fs to fix get_user_pages()/DMA races.
So give me some time to go through and understand what xfs/dax/mm stack
is doing for these races and try to fix it properly.
Thanks
Vivek
next prev parent reply other threads:[~2019-07-18 20:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 22:35 [Virtio-fs] [PATCH] Virtiofs: fix null pointer deference in directIO Liu Bo
2019-07-18 0:21 ` Liu Bo
2019-07-18 18:18 ` Vivek Goyal
2019-07-18 18:58 ` Liu Bo
2019-07-18 20:51 ` Vivek Goyal [this message]
2019-07-18 23:39 ` Liu Bo
2019-07-19 19:51 ` Vivek Goyal
2019-07-20 2:34 ` Liu Bo
2019-07-30 15:30 ` Vivek Goyal
2019-07-30 22:29 ` Liu Bo
2019-07-31 12:39 ` Vivek Goyal
2019-07-31 17:53 ` Liu Bo
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=20190718205110.GB30636@redhat.com \
--to=vgoyal@redhat.com \
--cc=bo.liu@linux.alibaba.com \
--cc=virtio-fs@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.