virtiofsd: handle NULL dir in lo_do_lookup
PATCH 1/1 virtiofsd: handle NULL dir in lo_do_lookup
Reported by fstests/generic/467.
open_by_handle_at() called from fuse inside guest can carry fuse mount point to daemon but lo_do_lookup() doesn't know its inode info because it's out of fuse's scope, thus lo_inode(req, parent) ends up with returning a NULL dir and breaks virtiofsd immediately.
Note that it'd break applications that uses open_by_handle_at.
It seems to me that nothing could be done to support open_by_handle_at in this case.
This simply tells fuse a ENOENT error so that open_by_handle_at() in guest can get a ESTALE.
--- contrib/virtiofsd/passthrough_ll.c | 8 ++++++++ 1 file changed, 8 insertions(+)
contrib/virtiofsd/passthrough_ll.c +8 -0
@@ -640,6 +640,14 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,struct lo_data *lo =lo_data (req);struct lo_inode *inode, *dir =lo_inode (req, parent); +/* +* name_to_handle_at() and open_by_handle_at() can reach here with fuse +* mount point in guest, but we don't have its inode info in the +* ino_map. +*/ +if (!dir) +return ENOENT ; +memset (e,0 ,sizeof (*e)); e->attr_timeout = lo->timeout; e->entry_timeout = lo->timeout;
Signature · 1 line
1.8.3.1
Quoted 11 lines · Liu Bo
Reported by fstests/generic/467.
open_by_handle_at()called from fuse inside guest can carry fuse mount point to daemon butlo_do_lookup()doesn't know its inode info because it's out of fuse's scope, thuslo_inode(req, parent)ends up with returning a NULL dir and breaks virtiofsd immediately.Note that it'd break applications that uses
open_by_handle_at.It seems to me that nothing could be done to support
open_by_handle_atin this case.
Then perhaps we should consider disabling exportfs support in virtio-fs case? I noticed that currently fuse set
sb->s_export_op = &fuse_export_operations
unconditionally, maybe we could implement a feature mask in fuse and let filesystem implementation registers what features it supports, e.g. exportfs in this case.
Or we could try adding real exportfs support to virtiofs? Though I'm not sure if it's possible or worth it at the moment.
Quoted 5 lines
This simply tells fuse a ENOENT error so that
open_by_handle_at()in guest can get a ESTALE.Signed-off-by Liu Bo <[email protected]>
The patch itself looks fine to me.
Thanks,
Eryu
Quoted 30 lines
--- contrib/virtiofsd/passthrough_ll.c | 8 ++++++++ 1 file changed, 8 insertions(+)contrib/virtiofsd/passthrough_ll.c +8
-0@@ -640,6 +640,14 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,struct lo_data *lo =lo_data (req);struct lo_inode *inode, *dir =lo_inode (req, parent); +/* +* name_to_handle_at() and open_by_handle_at() can reach here with fuse +* mount point in guest, but we don't have its inode info in the +* ino_map. +*/ +if (!dir) +return ENOENT ; +memset (e,0 ,sizeof (*e)); e->attr_timeout = lo->timeout; e->entry_timeout = lo->timeout;Signature · 6 lines
1.8.3.1 _______________________________________________ Virtio-fs mailing list [email protected] https://www.redhat.com/mailman/listinfo/virtio-fs
Quoted 16 lines · Eryu Guan
Quoted 11 lines · Liu Bo
Reported by fstests/generic/467.
open_by_handle_at()called from fuse inside guest can carry fuse mount point to daemon butlo_do_lookup()doesn't know its inode info because it's out of fuse's scope, thuslo_inode(req, parent)ends up with returning a NULL dir and breaks virtiofsd immediately.Note that it'd break applications that uses
open_by_handle_at.It seems to me that nothing could be done to support
open_by_handle_atin this case.Then perhaps we should consider disabling exportfs support in virtio-fs case? I noticed that currently fuse set
Quoted 8 lines
sb->s_export_op = &fuse_export_operationsunconditionally, maybe we could implement a feature mask in fuse and let filesystem implementation registers what features it supports, e.g. exportfs in this case.
Or we could try adding real exportfs support to virtiofs? Though I'm not sure if it's possible or worth it at the moment.
If we don't support export operations, we should disable it. Looks like we have enabled it in virtiofsd.
lo_init() {
if(conn->capable & FUSE_CAP_EXPORT_SUPPORT)
conn->want |= FUSE_CAP_EXPORT_SUPPORT;
}So if we were to disable it, I guess we will have to remove it.
Not sure if it is possible to support export ops in virtio-fs case. Need to read more about it.
Vivek
Quoted 29 lines · Vivek Goyal
Quoted 16 lines · Eryu Guan
Quoted 11 lines · Liu Bo
Reported by fstests/generic/467.
open_by_handle_at()called from fuse inside guest can carry fuse mount point to daemon butlo_do_lookup()doesn't know its inode info because it's out of fuse's scope, thuslo_inode(req, parent)ends up with returning a NULL dir and breaks virtiofsd immediately.Note that it'd break applications that uses
open_by_handle_at.It seems to me that nothing could be done to support
open_by_handle_atin this case.Then perhaps we should consider disabling exportfs support in virtio-fs case? I noticed that currently fuse set
Quoted 8 lines
sb->s_export_op = &fuse_export_operationsunconditionally, maybe we could implement a feature mask in fuse and let filesystem implementation registers what features it supports, e.g. exportfs in this case.
Or we could try adding real exportfs support to virtiofs? Though I'm not sure if it's possible or worth it at the moment.
If we don't support export operations, we should disable it. Looks like we have enabled it in virtiofsd.
Quoted 6 lines
lo_init() { if(conn->capable & FUSE_CAP_EXPORT_SUPPORT) conn->want |= FUSE_CAP_EXPORT_SUPPORT; }So if we were to disable it, I guess we will have to remove it.
Looks like only removing above lines doesn't disable export support (or only partially disabled), the test still runs & fails. Removing the EXPORT_SUPPORT cap only tells fuse to set fc->export_support to 0 and return -ESTALE on export operations like fuse_get_parent(), but the name_to_handle_at(2) syscall still could encode file into handle (which checks sb->s_export_op->fh_to_dentry), so the test thinks virtio-fs supports exports.
I have to reset sb->s_export_op to NULL when fc->export_support is 0 to make test not run, as there's no point to have a "half broken" export operations. This makes me wonder if we could remove fuse_conn.export_support field all together, as it serves no purpose when we don't have s_export_op set.
Thanks,
Eryu
Quoted 5 lines
Not sure if it is possible to support export ops in virtio-fs case. Need to read more about it.
Vivek
Quoted 12 lines · Liu Bo
Reported by fstests/generic/467.
open_by_handle_at()called from fuse inside guest can carry fuse mount point to daemon butlo_do_lookup()doesn't know its inode info because it's out of fuse's scope, thuslo_inode(req, parent)ends up with returning a NULL dir and breaks virtiofsd immediately.Note that it'd break applications that uses
open_by_handle_at.It seems to me that nothing could be done to support
open_by_handle_atin this case.
Quoted 7 lines
This simply tells fuse a ENOENT error so that
open_by_handle_at()in guest can get a ESTALE.Signed-off-by Liu Bo <[email protected]>--- contrib/virtiofsd/passthrough_ll.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Quoted 16 lines · * Stefan Hajnoczi ([email protected]) wrote:
Quoted 15 lines · Liu Bo
Reported by fstests/generic/467.
open_by_handle_at()called from fuse inside guest can carry fuse mount point to daemon butlo_do_lookup()doesn't know its inode info because it's out of fuse's scope, thuslo_inode(req, parent)ends up with returning a NULL dir and breaks virtiofsd immediately.Note that it'd break applications that uses
open_by_handle_at.It seems to me that nothing could be done to support
open_by_handle_atin this case.This simply tells fuse a ENOENT error so that
open_by_handle_at()in guest can get a ESTALE.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Liu Bo <[email protected]>--- contrib/virtiofsd/passthrough_ll.c | 8 ++++++++ 1 file changed, 8 insertions(+)Reviewed-by Stefan Hajnoczi <[email protected]>
OK, I've finally merged this.
Apologies for the delay; I got hung up on the questions about exportfs that had been asked at the time and wanted to understand that we had an answer.
Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK