]> git.hungrycats.org Git - linux/commit
ksmbd: prevent stale data from being written by SMB2 WRITE requests
authorNamjae Jeon <linkinjeon@kernel.org>
Tue, 3 Nov 2026 15:47:24 +0000 (10:47 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:13 +0000 (12:06 -0500)
commitfbe9fcda7ae8835b454c376de1d49232ab6bbcfb
tree73c968b7f4837ac61d32b8d43bb1d99edfb9ad07
parent2756a41a82d618bf1d8b41d74108311815cb695c
ksmbd: prevent stale data from being written by SMB2 WRITE requests

[ Upstream commit bc0e0f5ac1d7b044d403f859406b4b66d4b1ce9b ]

Initialize the compatibility byte in request buffers without zeroing
the entire allocation. Keep the one-byte compatibility exception for
SMB2 messages so valid zero-length WRITE requests remain compatible,
and validate the data range in the WRITE handlers against the current
compound request before accessing it.

This prevents stale request-buffer data from being written to files or
sent to IPC pipes.

Fixes: 443d61d1fa9f ("ksmbd: allocate one more byte for implied bcc[0]")
Cc: stable@vger.kernel.org
Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-32436
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: Inlined the unavailable smb2_current_req_len() helper and omitted the decompression change because compression support is absent. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/connection.c
fs/smb/server/smb2pdu.c