summaryrefslogtreecommitdiff
path: root/lib/test_fortify/write_overflow-memcpy.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2024-10-30 23:59:35 +0300
committerSteve French <stfrench@microsoft.com>2025-03-26 22:50:55 +0300
commitb26df4f57b6c42d6ecda281df8c0c2ec2f32885e (patch)
treeb16084ee2ef01437b2bb3f39c2858fd5deb12f2c /lib/test_fortify/write_overflow-memcpy.c
parent781802aa5a5950f99899f13ff9d760f5db81d36d (diff)
downloadlinux-b26df4f57b6c42d6ecda281df8c0c2ec2f32885e.tar.xz
cifs: Improve establishing SMB connection with NetBIOS session
Function ip_rfc1001_connect() send NetBIOS session request but currently does not read response. It even does not wait for the response. Instead it just calls usleep_range(1000, 2000) and explain in comment that some servers require short break before sending SMB negotiate packet. Response is later handled in generic is_smb_response() function called from cifs_demultiplex_thread(). That comment probably refers to the old DOS SMB server which cannot process incoming SMB negotiate packet if it has not sent NetBIOS session response packet. Note that current sleep timeout is too small when trying to establish connection to DOS SMB server running in qemu virtual machine connected over qemu user networking with guestfwd netcat options. So that usleep_range() call is not useful at all. NetBIOS session response packet contains useful error information, like the server name specified NetBIOS session request packet is incorrect. Old Windows SMB servers and even the latest SMB server on the latest Windows Server 2022 version requires that the name is the correct server name, otherwise they return error RFC1002_NOT_PRESENT. This applies for all SMB dialects (old SMB1, and also modern SMB2 and SMB3). Therefore read the reply of NetBIOS session request and implement parsing of the reply. Log received error to dmesg to help debugging reason why connection was refused. Also convert NetBIOS error to useful errno. Note that ip_rfc1001_connect() function is used only when doing connection over port 139. So the common SMB scenario over port 445 is not affected by this change at all. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'lib/test_fortify/write_overflow-memcpy.c')
0 files changed, 0 insertions, 0 deletions