Skip to content

Commit 79ed288

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix wrong next length validation of ea buffer in smb2_set_ea()
There are multiple smb2_ea_info buffers in FILE_FULL_EA_INFORMATION request from client. ksmbd find next smb2_ea_info using ->NextEntryOffset of current smb2_ea_info. ksmbd need to validate buffer length Before accessing the next ea. ksmbd should check buffer length using buf_len, not next variable. next is the start offset of current ea that got from previous ea. Cc: stable@vger.kernel.org Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-21598 Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 5aa4fda commit 79ed288

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,9 +2324,16 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23242324
break;
23252325
buf_len -= next;
23262326
eabuf = (struct smb2_ea_info *)((char *)eabuf + next);
2327-
if (next < (u32)eabuf->EaNameLength + le16_to_cpu(eabuf->EaValueLength))
2327+
if (buf_len < sizeof(struct smb2_ea_info)) {
2328+
rc = -EINVAL;
23282329
break;
2330+
}
23292331

2332+
if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength +
2333+
le16_to_cpu(eabuf->EaValueLength)) {
2334+
rc = -EINVAL;
2335+
break;
2336+
}
23302337
} while (next != 0);
23312338

23322339
kfree(attr_name);

0 commit comments

Comments
 (0)