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;
