]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cifs: Fix establishing NetBIOS session for SMB2+ connection
authorPali Rohár <pali@kernel.org>
Wed, 30 Oct 2024 21:46:20 +0000 (22:46 +0100)
committerSteve French <stfrench@microsoft.com>
Wed, 26 Mar 2025 19:50:51 +0000 (14:50 -0500)
commit781802aa5a5950f99899f13ff9d760f5db81d36d
tree18dbd56dd7d87faf243f27c8683930a9c9df1b4d
parentad9364a6835c45c52f47587ffbe0577bb7cd4c5b
cifs: Fix establishing NetBIOS session for SMB2+ connection

Function ip_rfc1001_connect() which establish NetBIOS session for SMB
connections, currently uses smb_send() function for sending NetBIOS Session
Request packet. This function expects that the passed buffer is SMB packet
and for SMB2+ connections it mangles packet header, which breaks prepared
NetBIOS Session Request packet. Result is that this function send garbage
packet for SMB2+ connection, which SMB2+ server cannot parse. That function
is not mangling packets for SMB1 connections, so it somehow works for SMB1.

Fix this problem and instead of smb_send(), use smb_send_kvec() function
which does not mangle prepared packet, this function send them as is. Just
API of this function takes struct msghdr (kvec) instead of packet buffer.

[MS-SMB2] specification allows SMB2 protocol to use NetBIOS as a transport
protocol. NetBIOS can be used over TCP via port 139. So this is a valid
configuration, just not so common. And even recent Windows versions (e.g.
Windows Server 2022) still supports this configuration: SMB over TCP port
139, including for modern SMB2 and SMB3 dialects.

This change fixes SMB2 and SMB3 connections over TCP port 139 which
requires establishing of NetBIOS session. Tested that this change fixes
establishing of SMB2 and SMB3 connections with Windows Server 2022.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsproto.h
fs/smb/client/connect.c
fs/smb/client/transport.c