]> git.ipfire.org Git - thirdparty/linux.git/commit
smb: client: fix SMB1 TRANS2 multi-response truncation in SendReceive()
authorFrank Sorenson <sorenson@redhat.com>
Tue, 4 Aug 2026 19:21:12 +0000 (14:21 -0500)
committerSteve French <stfrench@microsoft.com>
Tue, 4 Aug 2026 23:17:02 +0000 (18:17 -0500)
commit26fa4d17c023dbe5427a92d3a7bd9ae1d1e58bc5
tree196a8bc90dcbc23a19607a3fa121f8d95a4f938a
parent4986410316b1ae0e63c6ce418e4eb196723626e7
smb: client: fix SMB1 TRANS2 multi-response truncation in SendReceive()

When a TRANS2 response is split across multiple secondary packets,
coalesce_t2() assembles the payload into the large response buffer.
Two bugs cause SendReceive() to copy only a small fraction of the
assembled buffer into the caller's output buffer.

This manifests when listing a large directory on an SMB1 share
(observed against Windows XP); the first getdents returns only
partial results, and subsequent getdents returns EINVAL.

Bug 1: coalesce_t2() computes the coalesced size as:

  *pdu_len += total_in_src;

cifs_demultiplex_thread() resets *pdu_len to each secondary's own
pdu_length before calling coalesce_t2(), so this accumulates from
the wrong baseline on every secondary after the first.

Bug 2: after reassembly, cifs_demultiplex_thread() sets
mid->resp_buf_size to the final secondary's raw packet size.  This
value is later used as the memcpy length, so only a portion of the
coalesced response is copied.

Fix both by replacing the stale *pdu_len arithmetic with
smbCalcSize(), which reads the BCC field that coalesce_t2()
maintains correctly throughout reassembly.

Fixes: 83bfbd0bb902 ("cifs: Remove the RFC1002 header from smb_hdr")
Cc: stable@vger.kernel.org
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
Reviewed-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb1transport.c