From patchwork Wed Dec 22 23:09:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Add a check for readlink in mapped mode. Date: Wed, 22 Dec 2010 13:09:43 -0000 From: jvrao X-Patchwork-Id: 76451 Message-Id: <1293059383-9443-1-git-send-email-jvrao@linux.vnet.ibm.com> To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, "Venkateswararao Jujjuri \(JV\)" Signed-off-by: Venkateswararao Jujjuri Reviewed-by: Stefan Hajnoczi --- hw/9pfs/virtio-9p-local.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index a8e7525..9a106d4 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -112,6 +112,13 @@ static ssize_t local_readlink(FsContext *fs_ctx, const char *path, ssize_t tsize = -1; if (fs_ctx->fs_sm == SM_MAPPED) { int fd; + mode_t tmp_mode; + /* Make sure that it is a symlink */ + if (getxattr(rpath(fs_ctx, path), "user.virtfs.mode", &tmp_mode, + sizeof(mode_t)) <= 0 || !(tmp_mode & S_IFLNK)) { + errno = EINVAL; + return -1; + } fd = open(rpath(fs_ctx, path), O_RDONLY); if (fd == -1) { return -1;