Skip to content

Commit 374a7f4

Browse files
committed
Merge tag '6.5-rc5-ksmbd-server' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: "Two ksmbd server fixes, both also for stable: - improve buffer validation when multiple EAs returned - missing check for command payload size" * tag '6.5-rc5-ksmbd-server' of git://git.samba.org/ksmbd: ksmbd: fix wrong next length validation of ea buffer in smb2_set_ea() ksmbd: validate command request size
2 parents b4f63b0 + 79ed288 commit 374a7f4

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

fs/smb/server/smb2misc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
380380
}
381381

382382
if (smb2_req_struct_sizes[command] != pdu->StructureSize2) {
383-
if (command == SMB2_OPLOCK_BREAK_HE &&
384-
le16_to_cpu(pdu->StructureSize2) != OP_BREAK_STRUCT_SIZE_20 &&
385-
le16_to_cpu(pdu->StructureSize2) != OP_BREAK_STRUCT_SIZE_21) {
383+
if (!(command == SMB2_OPLOCK_BREAK_HE &&
384+
(le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_20 ||
385+
le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_21))) {
386386
/* special case for SMB2.1 lease break message */
387387
ksmbd_debug(SMB,
388-
"Illegal request size %d for oplock break\n",
389-
le16_to_cpu(pdu->StructureSize2));
388+
"Illegal request size %u for command %d\n",
389+
le16_to_cpu(pdu->StructureSize2), command);
390390
return 1;
391391
}
392392
}

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)