Skip to content

Commit

Permalink
Merge tag '6.7-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/…
Browse files Browse the repository at this point in the history
…cifs-2.6

Pull smb client fixes from Steve French:

 - multichannel fixes (including a lock ordering fix and an important
   refcounting fix)

 - spnego fix

* tag '6.7-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: fix lock ordering while disabling multichannel
  cifs: fix leak of iface for primary channel
  cifs: fix check of rc in function generate_smb3signingkey
  cifs: spnego: add ';' in HOST_KEY_LEN
  • Loading branch information
Linus Torvalds committed Nov 18, 2023
2 parents 05aa69b + 5eef12c commit 33b63f1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions fs/smb/client/cifs_spnego.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ struct key_type cifs_spnego_key_type = {
* strlen(";sec=ntlmsspi") */
#define MAX_MECH_STR_LEN 13

/* strlen of "host=" */
#define HOST_KEY_LEN 5
/* strlen of ";host=" */
#define HOST_KEY_LEN 6

/* strlen of ";ip4=" or ";ip6=" */
#define IP_KEY_LEN 5
Expand Down
6 changes: 6 additions & 0 deletions fs/smb/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,12 @@ void __cifs_put_smb_ses(struct cifs_ses *ses)
ses->chans[i].server = NULL;
}

/* we now account for primary channel in iface->refcount */
if (ses->chans[0].iface) {
kref_put(&ses->chans[0].iface->refcount, release_iface);
ses->chans[0].server = NULL;
}

sesInfoFree(ses);
cifs_put_tcp_session(server, 0);
}
Expand Down
22 changes: 13 additions & 9 deletions fs/smb/client/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,28 +322,32 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)
iface = ses->chans[i].iface;
server = ses->chans[i].server;

/*
* remove these references first, since we need to unlock
* the chan_lock here, since iface_lock is a higher lock
*/
ses->chans[i].iface = NULL;
ses->chans[i].server = NULL;
spin_unlock(&ses->chan_lock);

if (iface) {
spin_lock(&ses->iface_lock);
kref_put(&iface->refcount, release_iface);
ses->chans[i].iface = NULL;
iface->num_channels--;
if (iface->weight_fulfilled)
iface->weight_fulfilled--;
spin_unlock(&ses->iface_lock);
}

spin_unlock(&ses->chan_lock);
if (server && !server->terminate) {
server->terminate = true;
cifs_signal_cifsd_for_reconnect(server, false);
}
spin_lock(&ses->chan_lock);

if (server) {
ses->chans[i].server = NULL;
if (!server->terminate) {
server->terminate = true;
cifs_signal_cifsd_for_reconnect(server, false);
}
cifs_put_tcp_session(server, false);
}

spin_lock(&ses->chan_lock);
}

done:
Expand Down
5 changes: 2 additions & 3 deletions fs/smb/client/smb2transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ generate_smb3signingkey(struct cifs_ses *ses,
ptriplet->encryption.context,
ses->smb3encryptionkey,
SMB3_ENC_DEC_KEY_SIZE);
if (rc)
return rc;
rc = generate_key(ses, ptriplet->decryption.label,
ptriplet->decryption.context,
ses->smb3decryptionkey,
Expand All @@ -466,9 +468,6 @@ generate_smb3signingkey(struct cifs_ses *ses,
return rc;
}

if (rc)
return rc;

#ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS
cifs_dbg(VFS, "%s: dumping generated AES session keys\n", __func__);
/*
Expand Down

0 comments on commit 33b63f1

Please sign in to comment.