Skip to content

Commit

Permalink
cifs: sanitize paths in cifs_update_super_prepath.
Browse files Browse the repository at this point in the history
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: a310808 ("cifs: sanitize multiple delimiters in prepath")
Actually-Fixes: 24e0a1e ("cifs: switch to new mount api")
Signed-off-by: Thiago Rafael Becker <tbecker@redhat.com>
  • Loading branch information
trbecker authored and intel-lab-lkp committed Apr 4, 2023
1 parent 7e364e5 commit 4d179c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fs/cifs/fs_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -469,7 +469,7 @@ static char *sanitize_path(char *path)
cursor2--;

*(cursor2) = '\0';
return kstrdup(path, GFP_KERNEL);
return kstrdup(path, gfp);
}

/*
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion fs/cifs/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4d179c3

Please sign in to comment.