Skip to contentSkip to conversation

smb: client: terminate session upon failed client required signing

PATCH Applied Aaditya Kansal 2 participants 8 messages Feb 5 – Feb 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 smb: client: terminate session upon failed client required signing

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +8 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
 		iov[0].iov_base = mid->resp_buf;
 		iov[0].iov_len = len;
-		/* FIXME: add code to kill session */
+
 		rc = cifs_verify_signature(&rqst, server,
 					   mid->sequence_number);
-		if (rc)
+		if (rc) {
 			cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
 				 rc);
+
+			if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+				cifs_reconnect(server, true);
+				return rc;
+			}
+		}
 	}
 
 	/* BB special case reconnect tid and uid here? */
Signature · 1 line
2.52.0
#1 lore raw
Quoted 29 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +2 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
 		iov[0].iov_base = mid->resp_buf;
 		iov[0].iov_len = len;
-		/* FIXME: add code to kill session */
+
 		rc = cifs_verify_signature(&rqst, server,
 					   mid->sequence_number);
-		if (rc)
+		if (rc) {
 			cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 10 lines
fs/smb/client/cifstransport.c +6 -0
 				 rc);
+
+			if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+				cifs_reconnect(server, true);
+				return rc;
+			}
+		}
 	}
 
 	/* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

Signature · 1 line
-AK
Applied
#2 lore raw
Quoted 42 lines · Aaditya Kansal
Quoted 38 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +8 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
Quoted 2 lines

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 1 line
fs/smb/client/cifstransport.c +0 -0
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Have you verified the behavior of default (smb3.1.1) mounts as well?

Signature · 3 lines
Thanks,

Steve
#3 lore raw
Quoted 43 lines · Steve French
Quoted 41 lines · Aaditya Kansal
Quoted 38 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +8 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
Quoted 7 lines
Quoted 2 lines

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 1 line
fs/smb/client/cifstransport.c +0 -0
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Have you verified the behavior of default (smb3.1.1) mounts as well?

Thank you. Yes, I have checked it for the default version. Tested for both client required and server required signature verification.

Signature · 1 line
-AK
#4 lore raw
Quoted 48 lines · Aaditya Kansal
Quoted 45 lines · Steve French
Quoted 43 lines · Aaditya Kansal
Quoted 29 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +2 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 10 lines
fs/smb/client/cifstransport.c +6 -0
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

Quoted 7 lines
Quoted 5 lines

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Have you verified the behavior of default (smb3.1.1) mounts as well?

Thank you. Yes, I have checked it for the default version. Tested for both client required and server required signature verification.

You were able to verify (simulate) it as well for default ie SMB3.1.1 (not just for SMB1
which this patch fixes), and no changes needed for SMB3.1.1?

Signature · 3 lines
Thanks,

Steve
#5 lore raw
Quoted 51 lines · Steve French
Quoted 49 lines · Aaditya Kansal
Quoted 47 lines · Steve French
Quoted 40 lines · Aaditya Kansal
Quoted 38 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +8 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
Quoted 2 lines

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 1 line
fs/smb/client/cifstransport.c +0 -0
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Have you verified the behavior of default (smb3.1.1) mounts as well?

Thank you. Yes, I have checked it for the default version. Tested for both client required and server required signature verification.

You were able to verify (simulate) it as well for default ie SMB3.1.1 (not just for SMB1
which this patch fixes), and no changes needed for SMB3.1.1?

Yes, I verified for default version (3.1.1). First I set signing required option on server side,
then I set the sign flag on client side. SMB3.1.1 mounts with no issues.

Signature · 1 line
-AK
#6 lore raw
Quoted 59 lines · Aaditya Kansal
Quoted 55 lines · Steve French
Quoted 53 lines · Aaditya Kansal
Quoted 42 lines · Steve French
Quoted 40 lines · Aaditya Kansal
Quoted 38 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +8 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
Quoted 7 lines
Quoted 2 lines

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 1 line
fs/smb/client/cifstransport.c +0 -0
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Have you verified the behavior of default (smb3.1.1) mounts as well?

Thank you. Yes, I have checked it for the default version. Tested for both client required and server required signature verification.

Quoted 8 lines
Quoted 5 lines

You were able to verify (simulate) it as well for default ie SMB3.1.1 (not just for SMB1
which this patch fixes), and no changes needed for SMB3.1.1?

Yes, I verified for default version (3.1.1). First I set signing required option on server side,
then I set the sign flag on client side. SMB3.1.1 mounts with no issues.

How were you able to simulate bad signatures being sent from the server for SMB3.1.1? and for SMB1?

Signature · 3 lines
Thanks,

Steve
#7 lore raw
Quoted 63 lines · Steve French
Quoted 61 lines · Aaditya Kansal
Quoted 58 lines · Steve French
Quoted 44 lines · Aaditya Kansal
Quoted 43 lines · Steve French
Quoted 41 lines · Aaditya Kansal
Quoted 29 lines · Aaditya Kansal

Currently, when smb signature verification fails, the behaviour is to log the failure without any action to terminate the session.

Call cifs_reconnect() when client required signature verification fails. Otherwise, log the error without reconnecting.

---
Changes in v2:
- reconnect only triggered when client required signature verification fails

---
 fs/smb/client/cifstransport.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/client/cifstransport.c +2 -2
index 28d1cee90625..6c1fbf0bef6d 100644
@@ -169,12 +169,18 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
              iov[0].iov_base = mid->resp_buf;
              iov[0].iov_len = len;
-             /* FIXME: add code to kill session */
+
              rc = cifs_verify_signature(&rqst, server,
                                         mid->sequence_number);
-             if (rc)
+             if (rc) {
                      cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",

fs/smb/client/cifstransport.c cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · line 186

Quoted 10 lines
fs/smb/client/cifstransport.c +6 -0
                               rc);
+
+                     if (!(server->sec_mode & SECMODE_SIGN_REQUIRED)) {
+                             cifs_reconnect(server, true);
+                             return rc;
+                     }
+             }
      }
 
      /* BB special case reconnect tid and uid here? */

Hi, I am writing this as a ping for this patch. Thanks

Quoted 7 lines
Quoted 5 lines

merged into cifs-2.6.git for-next but had to rebase it to merge into current code.

Have you verified the behavior of default (smb3.1.1) mounts as well?

Thank you. Yes, I have checked it for the default version. Tested for both client required and server required signature verification.

You were able to verify (simulate) it as well for default ie SMB3.1.1 (not just for SMB1
which this patch fixes), and no changes needed for SMB3.1.1?

Quoted 6 lines
Quoted 3 lines

Yes, I verified for default version (3.1.1). First I set signing required option on server side,
then I set the sign flag on client side. SMB3.1.1 mounts with no issues.

How were you able to simulate bad signatures being sent from the server for SMB3.1.1? and for SMB1?

I changed the condition that checks cifs_verify_signature on client side and set it
to true, to ensure the failed signature verification path is hit. For cifs, it reconnected on
client required signature verification and for server side, it just logged the error.
For SMB3.1.1, the path doesn't hit and the behavior remains unchanged.

Signature · 1 line
-AK