]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Feb 2025 08:52:07 +0000 (09:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Feb 2025 08:52:07 +0000 (09:52 +0100)
added patches:
hostfs-add-const-qualifier-to-host_root-in-hostfs_fill_super.patch
hostfs-fix-the-host-directory-parse-when-mounting.patch

queue-6.6/hostfs-add-const-qualifier-to-host_root-in-hostfs_fill_super.patch [new file with mode: 0644]
queue-6.6/hostfs-fix-the-host-directory-parse-when-mounting.patch [new file with mode: 0644]
queue-6.6/series

diff --git a/queue-6.6/hostfs-add-const-qualifier-to-host_root-in-hostfs_fill_super.patch b/queue-6.6/hostfs-add-const-qualifier-to-host_root-in-hostfs_fill_super.patch
new file mode 100644 (file)
index 0000000..e3bb4b9
--- /dev/null
@@ -0,0 +1,44 @@
+From 104eef133fd9c17e4dc28bf43f592a86f26d8a59 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Tue, 11 Jun 2024 12:58:41 -0700
+Subject: hostfs: Add const qualifier to host_root in hostfs_fill_super()
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 104eef133fd9c17e4dc28bf43f592a86f26d8a59 upstream.
+
+After the recent conversion to the new mount API, there is a warning
+when building hostfs (which may be upgraded to an error via
+CONFIG_WERROR=y):
+
+  fs/hostfs/hostfs_kern.c: In function 'hostfs_fill_super':
+  fs/hostfs/hostfs_kern.c:942:27: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
+    942 |         char *host_root = fc->source;
+        |                           ^~
+
+Add the 'const' qualifier, as host_root will not be modified after its
+assignment. Move the assignment to keep the existing reverse Christmas
+tree order intact.
+
+Fixes: cd140ce9f611 ("hostfs: convert hostfs to use the new mount API")
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Link: https://lore.kernel.org/r/20240611-hostfs-fix-mount-api-conversion-v1-1-ef75bbc77f44@kernel.org
+Acked-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/hostfs/hostfs_kern.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/hostfs/hostfs_kern.c
++++ b/fs/hostfs/hostfs_kern.c
+@@ -925,8 +925,8 @@ static const struct inode_operations hos
+ static int hostfs_fill_super(struct super_block *sb, struct fs_context *fc)
+ {
+       struct hostfs_fs_info *fsi = sb->s_fs_info;
++      const char *host_root = fc->source;
+       struct inode *root_inode;
+-      char *host_root = fc->source;
+       int err;
+       sb->s_blocksize = 1024;
diff --git a/queue-6.6/hostfs-fix-the-host-directory-parse-when-mounting.patch b/queue-6.6/hostfs-fix-the-host-directory-parse-when-mounting.patch
new file mode 100644 (file)
index 0000000..70d40a4
--- /dev/null
@@ -0,0 +1,133 @@
+From ef9ca17ca458ac7253ae71b552e601e49311fc48 Mon Sep 17 00:00:00 2001
+From: Hongbo Li <lihongbo22@huawei.com>
+Date: Thu, 25 Jul 2024 14:51:30 +0800
+Subject: hostfs: fix the host directory parse when mounting.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Hongbo Li <lihongbo22@huawei.com>
+
+commit ef9ca17ca458ac7253ae71b552e601e49311fc48 upstream.
+
+hostfs not keep the host directory when mounting. When the host
+directory is none (default), fc->source is used as the host root
+directory, and this is wrong. Here we use `parse_monolithic` to
+handle the old mount path for parsing the root directory. For new
+mount path, The `parse_param` is used for the host directory parse.
+
+Reported-and-tested-by: Maciej Żenczykowski <maze@google.com>
+Fixes: cd140ce9f611 ("hostfs: convert hostfs to use the new mount API")
+Link: https://lore.kernel.org/all/CANP3RGceNzwdb7w=vPf5=7BCid5HVQDmz1K5kC9JG42+HVAh_g@mail.gmail.com/
+Cc: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
+Link: https://lore.kernel.org/r/20240725065130.1821964-1-lihongbo22@huawei.com
+[brauner: minor fixes]
+Signed-off-by: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/hostfs/hostfs_kern.c |   65 ++++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 55 insertions(+), 10 deletions(-)
+
+--- a/fs/hostfs/hostfs_kern.c
++++ b/fs/hostfs/hostfs_kern.c
+@@ -17,6 +17,7 @@
+ #include <linux/writeback.h>
+ #include <linux/mount.h>
+ #include <linux/fs_context.h>
++#include <linux/fs_parser.h>
+ #include <linux/namei.h>
+ #include "hostfs.h"
+ #include <init.h>
+@@ -925,7 +926,6 @@ static const struct inode_operations hos
+ static int hostfs_fill_super(struct super_block *sb, struct fs_context *fc)
+ {
+       struct hostfs_fs_info *fsi = sb->s_fs_info;
+-      const char *host_root = fc->source;
+       struct inode *root_inode;
+       int err;
+@@ -939,15 +939,6 @@ static int hostfs_fill_super(struct supe
+       if (err)
+               return err;
+-      /* NULL is printed as '(null)' by printf(): avoid that. */
+-      if (fc->source == NULL)
+-              host_root = "";
+-
+-      fsi->host_root_path =
+-              kasprintf(GFP_KERNEL, "%s/%s", root_ino, host_root);
+-      if (fsi->host_root_path == NULL)
+-              return -ENOMEM;
+-
+       root_inode = hostfs_iget(sb, fsi->host_root_path);
+       if (IS_ERR(root_inode))
+               return PTR_ERR(root_inode);
+@@ -973,6 +964,58 @@ static int hostfs_fill_super(struct supe
+       return 0;
+ }
++enum hostfs_parma {
++      Opt_hostfs,
++};
++
++static const struct fs_parameter_spec hostfs_param_specs[] = {
++      fsparam_string_empty("hostfs",          Opt_hostfs),
++      {}
++};
++
++static int hostfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
++{
++      struct hostfs_fs_info *fsi = fc->s_fs_info;
++      struct fs_parse_result result;
++      char *host_root;
++      int opt;
++
++      opt = fs_parse(fc, hostfs_param_specs, param, &result);
++      if (opt < 0)
++              return opt;
++
++      switch (opt) {
++      case Opt_hostfs:
++              host_root = param->string;
++              if (!*host_root)
++                      host_root = "";
++              fsi->host_root_path =
++                      kasprintf(GFP_KERNEL, "%s/%s", root_ino, host_root);
++              if (fsi->host_root_path == NULL)
++                      return -ENOMEM;
++              break;
++      }
++
++      return 0;
++}
++
++static int hostfs_parse_monolithic(struct fs_context *fc, void *data)
++{
++      struct hostfs_fs_info *fsi = fc->s_fs_info;
++      char *host_root = (char *)data;
++
++      /* NULL is printed as '(null)' by printf(): avoid that. */
++      if (host_root == NULL)
++              host_root = "";
++
++      fsi->host_root_path =
++              kasprintf(GFP_KERNEL, "%s/%s", root_ino, host_root);
++      if (fsi->host_root_path == NULL)
++              return -ENOMEM;
++
++      return 0;
++}
++
+ static int hostfs_fc_get_tree(struct fs_context *fc)
+ {
+       return get_tree_nodev(fc, hostfs_fill_super);
+@@ -990,6 +1033,8 @@ static void hostfs_fc_free(struct fs_con
+ }
+ static const struct fs_context_operations hostfs_context_ops = {
++      .parse_monolithic = hostfs_parse_monolithic,
++      .parse_param    = hostfs_parse_param,
+       .get_tree       = hostfs_fc_get_tree,
+       .free           = hostfs_fc_free,
+ };
index 4422210ab977424d689480e1f26807068b2e1cda..01a135cf86455d81dc619994ca42edc7c2569c1f 100644 (file)
@@ -349,6 +349,8 @@ genksyms-fix-memory-leak-when-the-same-symbol-is-add.patch
 genksyms-fix-memory-leak-when-the-same-symbol-is-rea.patch
 hostfs-convert-hostfs-to-use-the-new-mount-api.patch
 hostfs-fix-string-handling-in-__dentry_name.patch
+hostfs-add-const-qualifier-to-host_root-in-hostfs_fill_super.patch
+hostfs-fix-the-host-directory-parse-when-mounting.patch
 risc-v-mark-riscv_v_init-as-__init.patch
 asoc-rockchip-i2s_tdm-re-add-the-set_sysclk-callback.patch
 io_uring-uring_cmd-use-cached-cmd_op-in-io_uring_cmd.patch