]> git.proxmox.com Git - qemu.git/commitdiff
hw/9pfs: use O_NOFOLLOW for mapped readlink operation
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 20 May 2013 17:34:29 +0000 (23:04 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 20 May 2013 21:23:43 +0000 (16:23 -0500)
With mapped security models like mapped-xattr and mapped-file, we save the
symlink target as file contents. Now if we ever expose a normal directory
with mapped security model and find real symlinks in export path, never
follow them and return proper error.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/virtio-9p-local.c

index f1b1c83a2269977ed20f797dc6f1008c30814346..aeaecd8c3617e31e5923d37da79b17afe6f060ab 100644 (file)
@@ -284,7 +284,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
     if ((fs_ctx->export_flags & V9FS_SM_MAPPED) ||
         (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) {
         int fd;
-        fd = open(rpath(fs_ctx, path, buffer), O_RDONLY);
+        fd = open(rpath(fs_ctx, path, buffer), O_RDONLY | O_NOFOLLOW);
         if (fd == -1) {
             return -1;
         }