Skip to contentSkip to conversation

CVE-2026-31705: ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 1

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment

smb2_get_ea() applies 4-byte alignment padding via memset() after writing each EA entry. The bounds check on buf_free_len is performed before the value memcpy, but the alignment memset fires unconditionally afterward with no check on remaining space.

When the EA value exactly fills the remaining buffer (buf_free_len == 0 after value subtraction), the alignment memset writes 1-3 NUL bytes past the buf_free_len boundary. In compound requests where the response buffer is shared across commands, the first command (e.g., READ) can consume most of the buffer, leaving a tight remainder for the QUERY_INFO EA response. The alignment memset then overwrites past the physical kvmalloc allocation into adjacent kernel heap memory.

Add a bounds check before the alignment memset to ensure buf_free_len can accommodate the padding bytes.

This is the same bug pattern fixed by commit beef2634f81f ("ksmbd: fix potencial OOB in get_file_all_info() for compound requests") and commit fda9522ed6af ("ksmbd: fix OOB write in QUERY_INFO for compound requests"), both of which added bounds checks before unconditional writes in QUERY_INFO response handlers.

The Linux kernel CVE team has assigned CVE-2026-31705 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.6 with commit e2b76ab8b5c9327ab2dae6da05d0752eb2f4771d and fixed in 6.6.136 with commit ffbce350c6fd1e99116ea57383b9031717e36d3b
	Issue introduced in 6.6 with commit e2b76ab8b5c9327ab2dae6da05d0752eb2f4771d and fixed in 6.12.84 with commit 98f3de6ef4efbd899348d333f0902dc4ff14380c
	Issue introduced in 6.6 with commit e2b76ab8b5c9327ab2dae6da05d0752eb2f4771d and fixed in 6.18.25 with commit 790304c02bf9bd7b8171feda4294d6e62d32ae8f
	Issue introduced in 6.6 with commit e2b76ab8b5c9327ab2dae6da05d0752eb2f4771d and fixed in 7.0.2 with commit 922d48fe8c19f388ffa2f709f33acaae4e408de2
	Issue introduced in 6.6 with commit e2b76ab8b5c9327ab2dae6da05d0752eb2f4771d and fixed in 7.1-rc1 with commit 30010c952077a1c89ecdd71fc4d574c75a8f5617
	Issue introduced in 5.15.145 with commit f2283680a80571ca82d710bc6ecd8f8beac67d63
	Issue introduced in 6.1.71 with commit 9f297df20d93411c0b4ddad7f88ba04a7cd36e77

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2026-31705

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
fs/smb/server/smb2pdu.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/ffbce350c6fd1e99116ea57383b9031717e36d3b
	https://git.kernel.org/stable/c/98f3de6ef4efbd899348d333f0902dc4ff14380c
	https://git.kernel.org/stable/c/790304c02bf9bd7b8171feda4294d6e62d32ae8f
	https://git.kernel.org/stable/c/922d48fe8c19f388ffa2f709f33acaae4e408de2
	https://git.kernel.org/stable/c/30010c952077a1c89ecdd71fc4d574c75a8f5617