summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-11 09:20:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-11 09:37:33 +0100
commitf55d1ee3a43cec45232f18542c9b5841ac8527c2 (patch)
treec4b05fc448adafedea4731affe417525c947d6e9
parentdd942aca6445eb8dd5447422fdb5c0c829f716bf (diff)
downloadlinux-f55d1ee3a43cec45232f18542c9b5841ac8527c2.tar.gz
linux-f55d1ee3a43cec45232f18542c9b5841ac8527c2.tar.bz2
linux-f55d1ee3a43cec45232f18542c9b5841ac8527c2.zip
Revert "hostfs: fix string handling in __dentry_name()"
This reverts commit 86ec56b25476758f708328b2eeed68918567efd0 which is commit 60a6002432448bb3f291d80768ae98d62efc9c77 upstream. It is reported to cause build issues and odds are the root problem isn't really an issue on the 6.6.y branch anyway. If it is, someone can provide a working set of backported patches. Reported-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/cd10a924-ae65-4b02-aea2-e629947ca7a3@roeck-us.net Cc: Hongbo Li <lihongbo22@huawei.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Sasha Levin <sashal@kernel.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/hostfs/hostfs_kern.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 1efbcfa1f1f8..1fb8eacb9817 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -93,17 +93,32 @@ __uml_setup("hostfs=", hostfs_args,
static char *__dentry_name(struct dentry *dentry, char *name)
{
char *p = dentry_path_raw(dentry, name, PATH_MAX);
- struct hostfs_fs_info *fsi = dentry->d_sb->s_fs_info;
- char *root = fsi->host_root_path;
- size_t len = strlen(root);
+ char *root;
+ size_t len;
+ struct hostfs_fs_info *fsi;
+
+ fsi = dentry->d_sb->s_fs_info;
+ root = fsi->host_root_path;
+ len = strlen(root);
+ if (IS_ERR(p)) {
+ __putname(name);
+ return NULL;
+ }
+
+ /*
+ * This function relies on the fact that dentry_path_raw() will place
+ * the path name at the end of the provided buffer.
+ */
+ BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);
- if (IS_ERR(p) || len > p - name) {
+ strscpy(name, root, PATH_MAX);
+ if (len > p - name) {
__putname(name);
return NULL;
}
- memcpy(name, root, len);
- memmove(name + len, p, name + PATH_MAX - p);
+ if (p > name + len)
+ strcpy(name + len, p);
return name;
}