virtio-9p: Security model for chown
mapped model changes the owner in the extended attributes.
passthrough model does the change through lchown() as the
server don't need to follow the link and client will send the
actual filesystem object.
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 9bdcf02..1d7cb32 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -240,9 +240,14 @@
}
-static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid)
+static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
{
- return chown(rpath(ctx, path), uid, gid);
+ if (fs_ctx->fs_sm == SM_MAPPED) {
+ return local_set_xattr(rpath(fs_ctx, path), credp);
+ } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+ return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
+ }
+ return -1;
}
static int local_utime(FsContext *ctx, const char *path,