Skip to contentSkip to conversation

cifs: fail i/o on soft mounts if sessionsetup errors out

PATCH In review Ronnie Sahlberg 3 participants 3 messages Feb 5, 2020 – Feb 6, 2020

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

PATCH 1/1 cifs: fail i/o on soft mounts if sessionsetup errors out

RHBZ: 1579050

If we have a soft mount we should fail commands for session-setup failures (such as the password having changed/ account being deleted/ ...) and return an error back to the application.

---
 fs/cifs/smb2pdu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +8 -2
index 14f209f7376f..7996d81230aa 100644
@@ -350,9 +350,14 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
 	}
 
 	rc = cifs_negotiate_protocol(0, tcon->ses);
-	if (!rc && tcon->ses->need_reconnect)
+	if (!rc && tcon->ses->need_reconnect) {
 		rc = cifs_setup_session(0, tcon->ses, nls_codepage);
-
+		if ((rc == -EACCES) && !tcon->retry) {
+			rc = -EHOSTDOWN;
+			mutex_unlock(&tcon->ses->session_mutex);
+			goto failed;
+		}
+	}
 	if (rc || !tcon->need_reconnect) {
 		mutex_unlock(&tcon->ses->session_mutex);
 		goto out;
@@ -397,6 +402,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
 	case SMB2_SET_INFO:
 		rc = -EAGAIN;
 	}
+failed:
 	unload_nls(nls_codepage);
 	return rc;
 }
Signature · 1 line
2.13.6
#1 lore raw

Added cc:stable and merged into cifs-2.6.git for-next

Quoted 44 lines · Ronnie Sahlberg

RHBZ: 1579050

If we have a soft mount we should fail commands for session-setup failures (such as the password having changed/ account being deleted/ ...) and return an error back to the application.

---
 fs/cifs/smb2pdu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +8 -3
index 14f209f7376f..7996d81230aa 100644
@@ -350,9 +350,14 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
        }
 
        rc = cifs_negotiate_protocol(0, tcon->ses);
-       if (!rc && tcon->ses->need_reconnect)
+       if (!rc && tcon->ses->need_reconnect) {
                rc = cifs_setup_session(0, tcon->ses, nls_codepage);
-
+               if ((rc == -EACCES) && !tcon->retry) {
+                       rc = -EHOSTDOWN;
+                       mutex_unlock(&tcon->ses->session_mutex);
+                       goto failed;
+               }
+       }
        if (rc || !tcon->need_reconnect) {
                mutex_unlock(&tcon->ses->session_mutex);
                goto out;
@@ -397,6 +402,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
        case SMB2_SET_INFO:
                rc = -EAGAIN;
        }
+failed:
        unload_nls(nls_codepage);
        return rc;
 }
--

2.13.6

Signature · 3 lines
Thanks,

Steve
#2 lore raw
Quoted 3 lines · Steve French
Quoted 3 lines

If we have a soft mount we should fail commands for session-setup failures (such as the password having changed/ account being deleted/ ...) and return an error back to the application.

Looks good to me but we need to make sure it doesnt break failover on the buildbot.

Cheers,

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)