diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-03-20 15:48:06 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-03-27 08:32:41 +0100 |
commit | ebc4796bd2f75ea9e6c441e04e73be596b33145a (patch) | |
tree | 47a0fc293a827fad01e3a55206d6efc33d16c821 /patches | |
parent | c9c2367244890a6770b42fd175737222a24d8d10 (diff) | |
download | ptxdist-ebc4796bd2f75ea9e6c441e04e73be596b33145a.tar.gz ptxdist-ebc4796bd2f75ea9e6c441e04e73be596b33145a.tar.xz |
host-qemu: handle symlinks with 9p and security_model=mapped-file
Without this and security_model=mapped-file any symlink must be a regular
file and the symlink target should be inside the virtfs metadata.
With this patch regular symlinks are also accepted and created.
This makes it possible to use the same directory with
security_model=mapped-file, security_model=none and as a regular nfsroot.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'patches')
-rw-r--r-- | patches/qemu-4.2.0/0001-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch | 89 | ||||
-rw-r--r-- | patches/qemu-4.2.0/series | 4 |
2 files changed, 93 insertions, 0 deletions
diff --git a/patches/qemu-4.2.0/0001-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch b/patches/qemu-4.2.0/0001-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch new file mode 100644 index 000000000..3f73a6e02 --- /dev/null +++ b/patches/qemu-4.2.0/0001-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch @@ -0,0 +1,89 @@ +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 | 44 +++++++++++++++++++++++++++++--------------- + 1 file changed, 29 insertions(+), 15 deletions(-) + +diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c +index 4708c0bd896f..23909e91d5f1 100644 +--- a/hw/9pfs/9p-local.c ++++ b/hw/9pfs/9p-local.c +@@ -455,8 +455,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); +@@ -468,6 +467,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, + } while (tsize == -1 && errno == EINTR); + 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); +@@ -479,6 +479,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); +@@ -881,20 +892,23 @@ 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); +- do { +- write_size = write(fd, (void *)oldpath, oldpath_size); +- } while (write_size == -1 && errno == EINTR); +- 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); ++ do { ++ write_size = write(fd, (void *)oldpath, oldpath_size); ++ } while (write_size == -1 && errno == EINTR); ++ close_preserve_errno(fd); + +- if (write_size != oldpath_size) { +- goto err_end; ++ if (write_size != oldpath_size) { ++ goto err_end; ++ } + } + /* Set cleint credentials in symlink's xattr */ + credp->fc_mode = credp->fc_mode | S_IFLNK; diff --git a/patches/qemu-4.2.0/series b/patches/qemu-4.2.0/series new file mode 100644 index 000000000..428464314 --- /dev/null +++ b/patches/qemu-4.2.0/series @@ -0,0 +1,4 @@ +# generated by git-ptx-patches +#tag:base --start-number 1 +0001-9pfs-allow-real-symlinks-for-security_model-mapped-f.patch +# 869f325e926e09af3628184f8fe7b1ec - git-ptx-patches magic |