Skip to contentSkip to conversation

smb/server: reject embedded NULs in EA names

PATCH New ChenXiaoSong 1 participant 1 message Nov 3

Subsystems (2)
lore
Share & tools
lore

ChenXiaoSong

author reviewer
#0 lore raw

PATCH 1/1 smb/server: reject embedded NULs in EA names

From: ChenXiaoSong <[email protected]>

A client can send "DOSATTRIB\0suffix" as an EA name. The check sees a name longer than "DOSATTRIB" and lets it through. But the VFS stops at the first '\0', so the request writes to "user.DOSATTRIB", which should be blocked.

Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")
---
 fs/smb/server/smb2pdu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +2 -1
index 9cb533a030f4..1be0de361c40 100644
@@ -3455,7 +3455,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 		if (!eabuf->EaNameLength)
 			goto next;
 
-		if (eabuf->name[eabuf->EaNameLength]) {
+		if (eabuf->name[eabuf->EaNameLength] ||
+		    memchr(eabuf->name, '\0', eabuf->EaNameLength)) {
 			rc = -EBADMSG;
 			break;
 		}
Signature · 1 line
2.55.0