From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umsqv-0005cu-Dx for qemu-devel@nongnu.org; Wed, 12 Jun 2013 17:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Umsqt-0000wD-Qd for qemu-devel@nongnu.org; Wed, 12 Jun 2013 17:45:13 -0400 Sender: fluxion From: Michael Roth Date: Wed, 12 Jun 2013 16:41:14 -0500 Message-Id: <1371073298-14519-3-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1371073298-14519-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1371073298-14519-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 02/26] hw/9pfs: use O_NOFOLLOW for mapped readlink operation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: "Aneesh Kumar K.V" 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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Aneesh Kumar K.V (cherry picked from commit aed858ce10ef09c7bdf03f73e75e772f567c74cd) Signed-off-by: Michael Roth --- hw/9pfs/virtio-9p-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 6ece6f7..87aa75d 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -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; } -- 1.7.9.5