Skip to content

Commit d9d1e31

Browse files
pcacjrsmfrench
authored andcommitted
smb: client: fix broken multichannel with krb5+signing
When mounting a share with 'multichannel,max_channels=n,sec=krb5i', the client was duplicating signing key for all secondary channels, thus making the server fail all commands sent from secondary channels due to bad signatures. Every channel has its own signing key, so when establishing a new channel with krb5 auth, make sure to use the new session key as the derived key to generate channel's signing key in SMB2_auth_kerberos(). Repro: $ mount.cifs //srv/share /mnt -o multichannel,max_channels=4,sec=krb5i $ sleep 5 $ umount /mnt $ dmesg ... CIFS: VFS: sign fail cmd 0x5 message id 0x2 CIFS: VFS: \\srv SMB signature verification returned error = -13 CIFS: VFS: sign fail cmd 0x5 message id 0x2 CIFS: VFS: \\srv SMB signature verification returned error = -13 CIFS: VFS: sign fail cmd 0x4 message id 0x2 CIFS: VFS: \\srv SMB signature verification returned error = -13 Reported-by: Xiaoli Feng <xifeng@redhat.com> Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de> Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Cc: David Howells <dhowells@redhat.com> Cc: linux-cifs@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 4fc3a43 commit d9d1e31

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

fs/smb/client/smb2pdu.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,19 +1714,17 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data)
17141714
is_binding = (ses->ses_status == SES_GOOD);
17151715
spin_unlock(&ses->ses_lock);
17161716

1717-
/* keep session key if binding */
1718-
if (!is_binding) {
1719-
kfree_sensitive(ses->auth_key.response);
1720-
ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
1721-
GFP_KERNEL);
1722-
if (!ses->auth_key.response) {
1723-
cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n",
1724-
msg->sesskey_len);
1725-
rc = -ENOMEM;
1726-
goto out_put_spnego_key;
1727-
}
1728-
ses->auth_key.len = msg->sesskey_len;
1717+
kfree_sensitive(ses->auth_key.response);
1718+
ses->auth_key.response = kmemdup(msg->data,
1719+
msg->sesskey_len,
1720+
GFP_KERNEL);
1721+
if (!ses->auth_key.response) {
1722+
cifs_dbg(VFS, "%s: can't allocate (%u bytes) memory\n",
1723+
__func__, msg->sesskey_len);
1724+
rc = -ENOMEM;
1725+
goto out_put_spnego_key;
17291726
}
1727+
ses->auth_key.len = msg->sesskey_len;
17301728

17311729
sess_data->iov[1].iov_base = msg->data + msg->sesskey_len;
17321730
sess_data->iov[1].iov_len = msg->secblob_len;

0 commit comments

Comments
 (0)