two cifs/smb3 client fixes, one for stable

-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE6fsu8pdIjtWE/DpLiiy9cAdyT1EFAmQx+FEACgkQiiy9cAdy
 T1FlAwwAwWXT25SD5AZBQdNNT/5GfnxYSqtO9p1TnE/ZSVEuujFCu0K4Ciw3njuS
 GtsrIfUkwYRvBNCIN+eqaNff1x3By3eHIVcZRRxidRc0qwQwsKIohMZHtbeXen7O
 IjJX/b7zJHIrzRSpntjMxe4gwlrkSrp4BMQmG6Y7GxwC+MLHxM4Gglifh/yxmMBX
 OqauYGl5oyJ6NzkzZ6fb/70OSWFmEKjXwzpa8SGipmm7udRNeau9m0ObTf2lc9yq
 i2/okR+H0PINHJLEy4HFt4KkQKiRBZSy0C2E9nO3r0C3IoCuD1W4ZY9BiJRg+xXS
 QYjPUVNFG7+aW/JsYUr6KeaDmGrw4PR2pttv7zj6tbANHq0FAOgsrYtNpwfkDaPR
 f9l0kRe75JNQIwtRDGUKY/iNbpgFKzuYojl7I7zVAYpQhQFswhXueQkQ+Nb9TUeq
 L63Olom0cQoeBA296T45li5suuUP1YmgUZlt2/X+a3PrYBU72aFukaShfkwde9gs
 kSUvF1rU
 =2VdA
 -----END PGP SIGNATURE-----

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.
This commit is contained in:
Linus Torvalds 2023-04-08 18:37:45 -07:00
commit cdc9718d5e
4 changed files with 12 additions and 8 deletions

View File

@ -120,7 +120,7 @@ again:
spin_lock(&server->srv_lock);
if (server->tcpStatus == CifsNeedReconnect) {
spin_unlock(&server->srv_lock);
mutex_lock(&ses->session_mutex);
mutex_unlock(&ses->session_mutex);
if (tcon->retry)
goto again;

View File

@ -441,13 +441,14 @@ out:
* but there are some bugs that prevent rename from working if there are
* multiple delimiters.
*
* Returns a sanitized duplicate of @path. The caller is responsible for
* cleaning up the original.
* Returns a sanitized duplicate of @path. @gfp indicates the GFP_* flags
* for kstrdup.
* The caller is responsible for freeing the original.
*/
#define IS_DELIM(c) ((c) == '/' || (c) == '\\')
static char *sanitize_path(char *path)
char *cifs_sanitize_prepath(char *prepath, gfp_t gfp)
{
char *cursor1 = path, *cursor2 = path;
char *cursor1 = prepath, *cursor2 = prepath;
/* skip all prepended delimiters */
while (IS_DELIM(*cursor1))
@ -469,7 +470,7 @@ static char *sanitize_path(char *path)
cursor2--;
*(cursor2) = '\0';
return kstrdup(path, GFP_KERNEL);
return kstrdup(prepath, gfp);
}
/*
@ -531,7 +532,7 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
if (!*pos)
return 0;
ctx->prepath = sanitize_path(pos);
ctx->prepath = cifs_sanitize_prepath(pos, GFP_KERNEL);
if (!ctx->prepath)
return -ENOMEM;

View File

@ -287,4 +287,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
*/
#define SMB3_MAX_DCLOSETIMEO (1 << 30)
#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
#endif

View File

@ -1195,7 +1195,7 @@ 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 = cifs_sanitize_prepath(prefix, GFP_ATOMIC);
if (!cifs_sb->prepath)
return -ENOMEM;