Skip to content

Commit 95d7a89

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: fix buffer validation by including null terminator size in EA length
The smb2_set_ea function, which handles Extended Attributes (EA), was performing buffer validation checks that incorrectly omitted the size of the null terminating character (+1 byte) for EA Name. This patch fixes the issue by explicitly adding '+ 1' to EaNameLength where the null terminator is expected to be present in the buffer, ensuring the validation accurately reflects the total required buffer size. Cc: stable@vger.kernel.org Reported-by: Roger <roger.andersen@protonmail.com> Reported-by: Stanislas Polu <spolu@dust.tt> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent cafb57f commit 95d7a89

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23632363
int rc = 0;
23642364
unsigned int next = 0;
23652365

2366-
if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength +
2366+
if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength + 1 +
23672367
le16_to_cpu(eabuf->EaValueLength))
23682368
return -EINVAL;
23692369

@@ -2440,7 +2440,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
24402440
break;
24412441
}
24422442

2443-
if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength +
2443+
if (buf_len < sizeof(struct smb2_ea_info) + eabuf->EaNameLength + 1 +
24442444
le16_to_cpu(eabuf->EaValueLength)) {
24452445
rc = -EINVAL;
24462446
break;

0 commit comments

Comments
 (0)