[PATCH] ksmbd: require NUL-terminated EA names

From: Yifan Zhang

Date: Mon Nov 02 2026 - 07:25:46 EST


smb2_set_ea() verifies that the byte reserved for the declared EA-name
terminator lies inside the request, but it does not verify that the byte is
zero. With SMB debug logging enabled, the name is passed to %s and the
diagnostic reads beyond the request allocation.

KASAN reports:

BUG: KASAN: slab-out-of-bounds in string
Read of size 1
string
vsnprintf
_printk
smb2_set_ea
smb2_set_info

Reject an EA entry whose declared terminator byte is nonzero.

The patched kernel returns STATUS_INVALID_PARAMETER without a KASAN report.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Yifan Zhang <yfzhang23@xxxxxxxxxxxxxx>
---
fs/smb/server/smb2pdu.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f5fe3cf8ba328..03c389c0348b8 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3419,6 +3419,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
if (!eabuf->EaNameLength)
goto next;

+ if (eabuf->name[eabuf->EaNameLength]) {
+ rc = -EINVAL;
+ break;
+ }
+
ksmbd_debug(SMB,
"name : <%s>, name_len : %u, value_len : %u, next : %u\n",
eabuf->name, eabuf->EaNameLength,
--
2.39.5 (Apple Git-154)