Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] cifs: sanitize paths in cifs_update_super_prepath.
@ 2023-04-04 18:59 Thiago Becker
  2023-04-04 19:54 ` Paulo Alcantara
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thiago Becker @ 2023-04-04 18:59 UTC (permalink / raw)
  To: sfrench, linux-cifs
  Cc: pc, lsahlber, sprasad, tom, trbecker, samba-technical,
	Thiago Becker

After a server reboot, clients are failing to move files with ENOENT.
This is caused by DFS referrals containing multiple separators, which
the server move call doesn't recognize.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=2182472
Fixes: a31080899d5f ("cifs: sanitize multiple delimiters in prepath")
Actually-Fixes: 24e0a1eff9e2 ("cifs: switch to new mount api")
Signed-off-by: Thiago Rafael Becker <tbecker@redhat.com>
---
 fs/cifs/fs_context.c | 6 +++---
 fs/cifs/misc.c       | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 6d13f8207e96a..c4d9139b89d29 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -445,7 +445,7 @@ int smb3_parse_opt(const char *options, const char *key, char **val)
  * cleaning up the original.
  */
 #define IS_DELIM(c) ((c) == '/' || (c) == '\\')
-static char *sanitize_path(char *path)
+char *sanitize_path(char *path, gfp_t gfp)
 {
 	char *cursor1 = path, *cursor2 = path;
 
@@ -469,7 +469,7 @@ static char *sanitize_path(char *path)
 		cursor2--;
 
 	*(cursor2) = '\0';
-	return kstrdup(path, GFP_KERNEL);
+	return kstrdup(path, gfp);
 }
 
 /*
@@ -531,7 +531,7 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
 	if (!*pos)
 		return 0;
 
-	ctx->prepath = sanitize_path(pos);
+	ctx->prepath = sanitize_path(pos, GFP_KERNEL);
 	if (!ctx->prepath)
 		return -ENOMEM;
 
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index b44fb51968bfb..e6f208110de83 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1190,12 +1190,14 @@ int match_target_ip(struct TCP_Server_Info *server,
 	return 0;
 }
 
+extern char *sanitize_path(char *path, gfp_t gfp);
+
 int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix)
 {
 	kfree(cifs_sb->prepath);
 
 	if (prefix && *prefix) {
-		cifs_sb->prepath = kstrdup(prefix, GFP_ATOMIC);
+		cifs_sb->prepath = sanitize_path(prefix, GFP_ATOMIC);
 		if (!cifs_sb->prepath)
 			return -ENOMEM;
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-04 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04 18:59 [PATCH] cifs: sanitize paths in cifs_update_super_prepath Thiago Becker
2023-04-04 19:54 ` Paulo Alcantara
2023-04-04 21:34 ` kernel test robot
2023-04-04 22:26 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox