hw/9pfs: Add new security model mapped-file.
PATCH 1/1 hw/9pfs: Add new security model mapped-file.
From: "Aneesh Kumar K.V" <[email protected]>
This enable us to do passthrough equivalent security model on NFS directory. NFS server mostly do root squashing and don't support xattr. Hence we cannot use 'passthrough' or 'mapped' security model
Also added "mapped-xattr" security to indicate earlier "mapped" security model Older name is still supported.
POSIX rules regarding ctime update on chmod are not followed by this security model.
--- fsdev/file-op-9p.h | 12 +- hw/9pfs/virtio-9p-device.c | 9 -- hw/9pfs/virtio-9p-local.c | 338 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 342 insertions(+), 17 deletions(-)
fsdev/file-op-9p.h +8 -4
@@ -56,11 +56,15 @@ typedef struct extended_ops {* On failure ignore the error. */ #define V9FS_SM_NONE 0x00000010 -#define V9FS_RDONLY 0x00000020 -#define V9FS_PROXY_SOCK_FD 0x00000040 -#define V9FS_PROXY_SOCK_NAME 0x00000080 +/* +* uid/gid part of .virtfs_meatadata namespace +*/ +#define V9FS_SM_MAPPED_FILE 0x00000020 +#define V9FS_RDONLY 0x00000040 +#define V9FS_PROXY_SOCK_FD 0x00000080 +#define V9FS_PROXY_SOCK_NAME 0x00000100 -#define V9FS_SEC_MASK 0x0000001C +#define V9FS_SEC_MASK 0x0000003Ctypedef struct FileOperations FileOperations ;
hw/9pfs/virtio-9p-device.c +0 -9
@@ -91,15 +91,6 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) s->ctx.fs_root =NULL ; } s->ctx.exops.get_st_gen =NULL ; - -if (fse->export_flags &V9FS_SM_PASSTHROUGH ) { - s->ctx.xops = passthrough_xattr_ops; - }else if (fse->export_flags &V9FS_SM_MAPPED ) { - s->ctx.xops = mapped_xattr_ops; - }else if (fse->export_flags &V9FS_SM_NONE ) { - s->ctx.xops = none_xattr_ops; - } - len =strlen (conf->tag);if (len >MAX_TAG_LEN -1 ) { fprintf(stderr, "mount tag '%s' (%d bytes) is longer than "
hw/9pfs/virtio-9p-local.c +334 -4
465 lines not on this page · raw message
Signature · 1 line
1.7.8.247.g10f4e.dirty
Quoted 8 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
This enable us to do passthrough equivalent security model on NFS directory. NFS server mostly do root squashing and don't support xattr. Hence we cannot use 'passthrough' or 'mapped' security model
Also added "mapped-xattr" security to indicate earlier "mapped" security model Older name is still supported.
Out of interest, did you do any performance comparison with mapped-xattr?
hw/9pfs/virtio-9p-local.c static int local_fstat(FsContext *fs_ctx, int fid_type, · line 584
Quoted 8 lines
hw/9pfs/virtio-9p-local.c +4
-0@@ -404,6 +578,10 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = tmp_dev; } +#if 0 + } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { + /* FIXME!! how to implement that for MAPPED_FILE */ +#endif
Lacking an implementation of fstat seems like a pretty major omission that isn't mentioned in the commit message.
Alex
Quoted 4 lines · Alex Bradbury
Quoted 2 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
Quoted 9 lines
Quoted 6 lines
This enable us to do passthrough equivalent security model on NFS directory. NFS server mostly do root squashing and don't support xattr. Hence we cannot use 'passthrough' or 'mapped' security model
Also added "mapped-xattr" security to indicate earlier "mapped" security model Older name is still supported.
Out of interest, did you do any performance comparison with mapped-xattr?
No, I was mostly looking at making virtFS usable on an NFS setup
Quoted 13 lines
hw/9pfs/virtio-9p-local.c static int local_fstat(FsContext *fs_ctx, int fid_type, · line 584
Quoted 9 lines
hw/9pfs/virtio-9p-local.c +4
-0@@ -404,6 +578,10 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = tmp_dev; } +#if 0 + } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { + /* FIXME!! how to implement that for MAPPED_FILE */ +#endif Lacking an implementation of fstat seems like a pretty major omission that isn't mentioned in the commit message.
If you look at where local_fstat get used currently, We do it only for lock call, that too to check whether the file is present. We are not using the stat value returned. So the patchset should be usable as it is. What i am contemplating is should i add additional code in server that fallback to path based stat if fs driver callback returned EOPNOTSUPP error. May be i should do that in the next version.
-aneesh