]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cifs: Fix negotiate retry functionality
authorPali Rohár <pali@kernel.org>
Sat, 2 Nov 2024 19:06:50 +0000 (20:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:12:23 +0000 (11:12 +0200)
commit5cb41fa3074d49c142a7b82a86defa9378a41cb8
treedbdcefa714f1ae57132e3cf49c101495c44553ea
parent67875b6bd7d108ab8a9d262cb0a618d68dd4ec07
cifs: Fix negotiate retry functionality

[ Upstream commit e94e882a6d69525c07589222cf3a6ff57ad12b5b ]

SMB negotiate retry functionality in cifs_negotiate() is currently broken
and does not work when doing socket reconnect. Caller of this function,
which is cifs_negotiate_protocol() requires that tcpStatus after successful
execution of negotiate callback stay in CifsInNegotiate. But if the
CIFSSMBNegotiate() called from cifs_negotiate() fails due to connection
issues then tcpStatus is changed as so repeated CIFSSMBNegotiate() call
does not help.

Fix this problem by moving retrying code from negotiate callback (which is
either cifs_negotiate() or smb2_negotiate()) to cifs_negotiate_protocol()
which is caller of those callbacks. This allows to properly handle and
implement correct transistions between tcpStatus states as function
cifs_negotiate_protocol() already handles it.

With this change, cifs_negotiate_protocol() now handles also -EAGAIN error
set by the RFC1002_NEGATIVE_SESSION_RESPONSE processing after reconnecting
with NetBIOS session.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/connect.c
fs/smb/client/smb1ops.c
fs/smb/client/smb2ops.c