Patchwork Add a check for readlink in mapped mode.

login
register
mail settings
Submitter jvrao
Date Dec. 22, 2010, 11:09 p.m.
Message ID <1293059383-9443-1-git-send-email-jvrao@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/76451/
State New
Headers show

Comments

jvrao - Dec. 22, 2010, 11:09 p.m.
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/9pfs/virtio-9p-local.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Stefan Hajnoczi - Dec. 23, 2010, 2:28 a.m.
On Wed, Dec 22, 2010 at 11:09 PM, Venkateswararao Jujjuri (JV)
<jvrao@linux.vnet.ibm.com> wrote:
> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
> ---
>  hw/9pfs/virtio-9p-local.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Patch

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;