Skip to content

Commit

Permalink
ksmbd: validate command request size
Browse files Browse the repository at this point in the history
In commit 2b9b8f3b68ed ("ksmbd: validate command payload size"), except
for SMB2_OPLOCK_BREAK_HE command, the request size of other commands
is not checked, it's not expected. Fix it by add check for request
size of other commands.

Fixes: 2b9b8f3b68ed ("ksmbd: validate command payload size")
Signed-off-by: Long Li <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
Long Li authored and namjaejeon committed Jul 29, 2023
1 parent b6da300 commit d6fb37b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions smb2misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
}

if (smb2_req_struct_sizes[command] != pdu->StructureSize2) {
if (command == SMB2_OPLOCK_BREAK_HE &&
le16_to_cpu(pdu->StructureSize2) != OP_BREAK_STRUCT_SIZE_20 &&
le16_to_cpu(pdu->StructureSize2) != OP_BREAK_STRUCT_SIZE_21) {
if (!(command == SMB2_OPLOCK_BREAK_HE &&
(le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_20 ||
le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_21))) {
/* special case for SMB2.1 lease break message */
ksmbd_debug(SMB,
"Illegal request size %d for oplock break\n",
le16_to_cpu(pdu->StructureSize2));
"Illegal request size %u for command %d\n",
le16_to_cpu(pdu->StructureSize2), command);
return 1;
}
}
Expand Down

0 comments on commit d6fb37b

Please sign in to comment.