Skip to content

Commit ac090d9

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: fix guest connection failure with nautilus
MS-SMB2 describe session sign like the following. Session.SigningRequired MUST be set to TRUE under the following conditions: - If the SMB2_NEGOTIATE_SIGNING_REQUIRED bit is set in the SecurityMode field of the client request. - If the SMB2_SESSION_FLAG_IS_GUEST bit is not set in the SessionFlags field and Session.IsAnonymous is FALSE and either Connection.ShouldSign or global RequireMessageSigning is TRUE. When trying guest account connection using nautilus, The login failure happened on session setup. ksmbd does not allow this connection when the user is a guest and the connection sign is set. Just do not set session sign instead of error response as described in the specification. And this change improves the guest connection in Nautilus. Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") Cc: [email protected] # v5.15+ Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b207602 commit ac090d9

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,11 +1464,6 @@ static int ntlm_authenticate(struct ksmbd_work *work)
14641464
}
14651465

14661466
if (user_guest(sess->user)) {
1467-
if (conn->sign) {
1468-
ksmbd_debug(SMB, "Guest login not allowed when signing enabled\n");
1469-
return -EPERM;
1470-
}
1471-
14721467
rsp->SessionFlags = SMB2_SESSION_FLAG_IS_GUEST_LE;
14731468
} else {
14741469
struct authenticate_message *authblob;
@@ -1481,38 +1476,39 @@ static int ntlm_authenticate(struct ksmbd_work *work)
14811476
ksmbd_debug(SMB, "authentication failed\n");
14821477
return -EPERM;
14831478
}
1479+
}
14841480

1485-
/*
1486-
* If session state is SMB2_SESSION_VALID, We can assume
1487-
* that it is reauthentication. And the user/password
1488-
* has been verified, so return it here.
1489-
*/
1490-
if (sess->state == SMB2_SESSION_VALID) {
1491-
if (conn->binding)
1492-
goto binding_session;
1493-
return 0;
1494-
}
1481+
/*
1482+
* If session state is SMB2_SESSION_VALID, We can assume
1483+
* that it is reauthentication. And the user/password
1484+
* has been verified, so return it here.
1485+
*/
1486+
if (sess->state == SMB2_SESSION_VALID) {
1487+
if (conn->binding)
1488+
goto binding_session;
1489+
return 0;
1490+
}
14951491

1496-
if ((conn->sign || server_conf.enforced_signing) ||
1497-
(req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
1498-
sess->sign = true;
1492+
if ((rsp->SessionFlags != SMB2_SESSION_FLAG_IS_GUEST_LE &&
1493+
(conn->sign || server_conf.enforced_signing)) ||
1494+
(req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
1495+
sess->sign = true;
14991496

1500-
if (smb3_encryption_negotiated(conn) &&
1501-
!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
1502-
rc = conn->ops->generate_encryptionkey(sess);
1503-
if (rc) {
1504-
ksmbd_debug(SMB,
1505-
"SMB3 encryption key generation failed\n");
1506-
return -EINVAL;
1507-
}
1508-
sess->enc = true;
1509-
rsp->SessionFlags = SMB2_SESSION_FLAG_ENCRYPT_DATA_LE;
1510-
/*
1511-
* signing is disable if encryption is enable
1512-
* on this session
1513-
*/
1514-
sess->sign = false;
1497+
if (smb3_encryption_negotiated(conn) &&
1498+
!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
1499+
rc = conn->ops->generate_encryptionkey(sess);
1500+
if (rc) {
1501+
ksmbd_debug(SMB,
1502+
"SMB3 encryption key generation failed\n");
1503+
return -EINVAL;
15151504
}
1505+
sess->enc = true;
1506+
rsp->SessionFlags = SMB2_SESSION_FLAG_ENCRYPT_DATA_LE;
1507+
/*
1508+
* signing is disable if encryption is enable
1509+
* on this session
1510+
*/
1511+
sess->sign = false;
15161512
}
15171513

15181514
binding_session:

0 commit comments

Comments
 (0)