Skip to content

Commit

Permalink
ksmbd: fix wrong next length validation of ea buffer in smb2_set_ea()
Browse files Browse the repository at this point in the history
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: [email protected]
Reported-by: [email protected] # ZDI-CAN-21598
Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
namjaejeon authored and Steve French committed Aug 6, 2023
1 parent 5aa4fda commit 79ed288
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/smb/server/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,9 +2324,16 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
break;
buf_len -= next;
eabuf = (struct smb2_ea_info *)((char *)eabuf + next);
if (next < (u32)eabuf->EaNameLength + le16_to_cpu(eabuf->EaValueLength))
if (buf_len < sizeof(struct smb2_ea_info)) {
rc = -EINVAL;
break;
}

if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength +
le16_to_cpu(eabuf->EaValueLength)) {
rc = -EINVAL;
break;
}
} while (next != 0);

kfree(attr_name);
Expand Down

0 comments on commit 79ed288

Please sign in to comment.