diff mbox

Fix SMB2_TREE_CONNECT requests with the wrong TreeId

Message ID 41c29ddb-eafa-dc03-ab2b-864919aa4192@fbihome.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan-Marek Glogowski Feb. 17, 2017, 10:55 a.m. UTC
Am 15.02.2017 um 15:24 schrieb Jan-Marek Glogowski:
> I won't be able to test the patch today but hopefully tomorrow,
> depending on the current LiMux stuff. I'm tired too. It compiled for my
> old kernel and should work.

Took some time to test the 2nd patch and it turned out it doesn't work.
The TreeId must be reset before small_smb2_init(SMB2_TREE_CONNECT, ...)
call, as this copies the tcon->tid into the smb2 header.

This is fixed in the attached patch.

Can I add "Reported-by" or "Tested-by" for myself and Suggested-by, and
Reviewed-by for you?

Do you want to test it?

Jan-Marek

Comments

Aurélien Aptel Feb. 17, 2017, 6:37 p.m. UTC | #1
I have reproduced the issue and can confirm your latest patch fixes it.

Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Tested-by: Aurelien Aptel <aaptel@suse.com>
diff mbox

Patch

From faf5ea71a567fa9f68daf296e0fa27823f968ee8 Mon Sep 17 00:00:00 2001
From: Jan-Marek Glogowski <glogow@fbihome.de>
Date: Fri, 10 Feb 2017 16:43:46 +0100
Subject: [PATCH] Reset TreeId to zero on SMB2_TREE_CONNECT

Currently the cifs module breaks the CIFS specs on reconnect as
described in http://msdn.microsoft.com/en-us/library/cc246529.aspx:

"TreeId (4 bytes): Uniquely identifies the tree connect for the
command. This MUST be 0 for the SMB2 TREE_CONNECT Request."

Signed-off-by: Jan-Marek Glogowski <glogow@fbihome.de>
---
 fs/cifs/smb2pdu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8745722..bdd3292 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1104,6 +1104,10 @@  static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 		return -EINVAL;
 	}
 
+	/* SMB2 TREE_CONNECT request must be called with TreeId == 0 */
+	if (tcon)
+		tcon->tid = 0;
+
 	rc = small_smb2_init(SMB2_TREE_CONNECT, tcon, (void **) &req);
 	if (rc) {
 		kfree(unc_path);
-- 
1.9.1