From: Andrey Erokhin <language.lawyer@gmail.com>
To: qemu-devel@nongnu.org
Subject: [PATCH] hw/9pfs: Follow native symlinks when security-model=mapped
Date: Thu, 20 Nov 2025 18:01:36 +0500 [thread overview]
Message-ID: <5e07267f-b990-47fc-ade7-934209ea942f@gmail.com> (raw)
A directory mounted via virtfs with security-model=mapped[-xattr|-file] can contain "native" symlinks
This can happen e.g. when booting from a rootfs directory tree (usually with writable overlay set up on the host side)
Currently, with security-model=mapped, QEMU expects that all host "symlinks" are in "mapped" format, i.e. are files containing the linked path, so it tries to open with O_NOFOLLOW and fails with ELOOP in case of a native symlink
This patch gives such cases a second chance: trying to open as a native symlink, by reusing security-model=[none|passthrough] else if branch
QEMU issues:
https://gitlab.com/qemu-project/qemu/-/issues/173 (from https://bugs.launchpad.net/qemu/+bug/1831354)
https://gitlab.com/qemu-project/qemu/-/issues/3088 (dup of the first one)
Signed-off-by: Andrey Erokhin <language.lawyer@gmail.com>
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 31e216227c..b4f8be2c81 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -468,12 +468,14 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
fd = local_open_nofollow(fs_ctx, fs_path->data, O_RDONLY, 0);
if (fd == -1) {
+ if (errno == ELOOP) goto native_symlink;
return -1;
}
tsize = RETRY_ON_EINTR(read(fd, (void *)buf, bufsz));
close_preserve_errno(fd);
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
+native_symlink:;
char *dirpath = g_path_get_dirname(fs_path->data);
char *name = g_path_get_basename(fs_path->data);
int dirfd;
next reply other threads:[~2025-11-20 14:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 13:01 Andrey Erokhin [this message]
2025-11-21 12:20 ` [PATCH] hw/9pfs: Follow native symlinks when security-model=mapped Christian Schoenebeck
2025-11-21 18:32 ` Andrey Erokhin
2025-11-22 12:23 ` Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e07267f-b990-47fc-ade7-934209ea942f@gmail.com \
--to=language.lawyer@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).