Skip to content

Commit cdc9718

Browse files
committed
Merge tag '6.3-rc5-smb3-cifs-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs client fixes from Steve French: "Two cifs/smb3 client fixes, one for stable: - double lock fix for a cifs/smb1 reconnect path - DFS prefixpath fix for reconnect when server moved" * tag '6.3-rc5-smb3-cifs-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: double lock in cifs_reconnect_tcon() cifs: sanitize paths in cifs_update_super_prepath.
2 parents 68047c4 + 4f5d5b3 commit cdc9718

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

fs/cifs/cifssmb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
120120
spin_lock(&server->srv_lock);
121121
if (server->tcpStatus == CifsNeedReconnect) {
122122
spin_unlock(&server->srv_lock);
123-
mutex_lock(&ses->session_mutex);
123+
mutex_unlock(&ses->session_mutex);
124124

125125
if (tcon->retry)
126126
goto again;

fs/cifs/fs_context.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,14 @@ int smb3_parse_opt(const char *options, const char *key, char **val)
441441
* but there are some bugs that prevent rename from working if there are
442442
* multiple delimiters.
443443
*
444-
* Returns a sanitized duplicate of @path. The caller is responsible for
445-
* cleaning up the original.
444+
* Returns a sanitized duplicate of @path. @gfp indicates the GFP_* flags
445+
* for kstrdup.
446+
* The caller is responsible for freeing the original.
446447
*/
447448
#define IS_DELIM(c) ((c) == '/' || (c) == '\\')
448-
static char *sanitize_path(char *path)
449+
char *cifs_sanitize_prepath(char *prepath, gfp_t gfp)
449450
{
450-
char *cursor1 = path, *cursor2 = path;
451+
char *cursor1 = prepath, *cursor2 = prepath;
451452

452453
/* skip all prepended delimiters */
453454
while (IS_DELIM(*cursor1))
@@ -469,7 +470,7 @@ static char *sanitize_path(char *path)
469470
cursor2--;
470471

471472
*(cursor2) = '\0';
472-
return kstrdup(path, GFP_KERNEL);
473+
return kstrdup(prepath, gfp);
473474
}
474475

475476
/*
@@ -531,7 +532,7 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
531532
if (!*pos)
532533
return 0;
533534

534-
ctx->prepath = sanitize_path(pos);
535+
ctx->prepath = cifs_sanitize_prepath(pos, GFP_KERNEL);
535536
if (!ctx->prepath)
536537
return -ENOMEM;
537538

fs/cifs/fs_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
287287
*/
288288
#define SMB3_MAX_DCLOSETIMEO (1 << 30)
289289
#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
290+
291+
extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
292+
290293
#endif

fs/cifs/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix)
11951195
kfree(cifs_sb->prepath);
11961196

11971197
if (prefix && *prefix) {
1198-
cifs_sb->prepath = kstrdup(prefix, GFP_ATOMIC);
1198+
cifs_sb->prepath = cifs_sanitize_prepath(prefix, GFP_ATOMIC);
11991199
if (!cifs_sb->prepath)
12001200
return -ENOMEM;
12011201

0 commit comments

Comments
 (0)