summaryrefslogtreecommitdiffstats
path: root/patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch')
-rw-r--r--patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch b/patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch
new file mode 100644
index 000000000..46b75f8a9
--- /dev/null
+++ b/patches/qemu-8.2.2/0100-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch
@@ -0,0 +1,85 @@
+From: Michael Olbrich <m.olbrich@pengutronix.de>
+Date: Tue, 25 Oct 2016 12:39:03 +0200
+Subject: [PATCH] 9pfs: allow real symlinks for security_model=mapped-file
+
+And create real symlinks if possible. This makes it possible to use the
+same filesystem with security_model=mapped-file and security_model=none.
+
+Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
+---
+ hw/9pfs/9p-local.c | 40 +++++++++++++++++++++++++++-------------
+ 1 file changed, 27 insertions(+), 13 deletions(-)
+
+diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
+index 1b1f3b9ec81e..d900dccaacb1 100644
+--- a/hw/9pfs/9p-local.c
++++ b/hw/9pfs/9p-local.c
+@@ -462,8 +462,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
+ {
+ ssize_t tsize = -1;
+
+- if ((fs_ctx->export_flags & V9FS_SM_MAPPED) ||
+- (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) {
++ if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
+ int fd;
+
+ fd = local_open_nofollow(fs_ctx, fs_path->data, O_RDONLY, 0);
+@@ -473,6 +472,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
+ 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_MAPPED_FILE) ||
+ (fs_ctx->export_flags & V9FS_SM_NONE)) {
+ char *dirpath = g_path_get_dirname(fs_path->data);
+ char *name = g_path_get_basename(fs_path->data);
+@@ -484,6 +484,17 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
+ }
+
+ tsize = readlinkat(dirfd, name, buf, bufsz);
++
++ if (tsize == -1 && (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) {
++ int fd = openat_file(dirfd, name, O_RDONLY, 0);
++ if (fd == -1) {
++ goto out;
++ }
++ do {
++ tsize = read(fd, (void *)buf, bufsz);
++ } while (tsize == -1 && errno == EINTR);
++ close_preserve_errno(fd);
++ }
+ close_preserve_errno(dirfd);
+ out:
+ g_free(name);
+@@ -899,18 +910,21 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
+ int fd;
+ ssize_t oldpath_size, write_size;
+
+- fd = openat_file(dirfd, name, O_CREAT | O_EXCL | O_RDWR,
+- fs_ctx->fmode);
+- if (fd == -1) {
+- goto out;
+- }
+- /* Write the oldpath (target) to the file. */
+- oldpath_size = strlen(oldpath);
+- write_size = RETRY_ON_EINTR(write(fd, (void *)oldpath, oldpath_size));
+- close_preserve_errno(fd);
++ if (fs_ctx->export_flags & V9FS_SM_MAPPED ||
++ (symlinkat(oldpath, dirfd, name) != 0)) {
++ fd = openat_file(dirfd, name, O_CREAT | O_EXCL | O_RDWR,
++ fs_ctx->fmode);
++ if (fd == -1) {
++ goto out;
++ }
++ /* Write the oldpath (target) to the file. */
++ oldpath_size = strlen(oldpath);
++ write_size = RETRY_ON_EINTR(write(fd, (void *)oldpath, oldpath_size));
++ close_preserve_errno(fd);
+
+- if (write_size != oldpath_size) {
+- goto err_end;
++ if (write_size != oldpath_size) {
++ goto err_end;
++ }
+ }
+ /* Set client credentials in symlink's xattr */
+ credp->fc_mode = credp->fc_mode | S_IFLNK;