]> git.ipfire.org Git - thirdparty/linux.git/commit
smb: client: fix buffer leaks in SMB1 read and write
authorDawei Feng <dawei.feng@seu.edu.cn>
Sun, 28 Jun 2026 06:59:09 +0000 (14:59 +0800)
committerSteve French <stfrench@microsoft.com>
Sun, 26 Jul 2026 22:40:20 +0000 (17:40 -0500)
commit6a3e16d60e81a4aa3056ab15617036cfbea2e07d
treed32a38738d2c1fcc97398ff131d5a2ddc36fb5b4
parent9349dd0646673964eb9e993050526029fc599677
smb: client: fix buffer leaks in SMB1 read and write

CIFSSMBRead(), CIFSSMBWrite() and CIFSSMBWrite2() allocate a request
buffer before checking whether tcon->ses->server is NULL. If that
defensive check ever fails, the helper returns -ECONNABORTED without
releasing the request buffer.

Fix these leaks by releasing the allocated request buffer before
returning from these error paths. Use cifs_small_buf_release() for the
buffers allocated by small_smb_init() and cifs_buf_release() for the
buffer allocated by smb_init().

The bug was first flagged by an experimental analysis tool we are
developing for kernel memory-management bugs while analyzing
v6.13-rc1. The tool is still under development and is not yet publicly
available. Manual inspection confirms that the bug is still
present in v7.1.1.

An x86_64 allyesconfig build showed no new warnings.

Runtime validation used a temporary fault-injection hook to force
tcon->ses->server to NULL after request-buffer initialization. On the
unfixed kernel, the harness observed two leaked small request buffers and
one leaked large request buffer, with directed kmemleak dumps confirming
the CIFS buffer allocation stacks. After the fix, no CIFS request-buffer
deltas remained.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dawei Feng <dawei.feng@seu.edu.cn>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifssmb.c