Skip to content

Commit

Permalink
fs: dlm: check on minimum msglen size
Browse files Browse the repository at this point in the history
[ Upstream commit 710176e ]

This patch adds an additional check for minimum dlm header size which is
an invalid dlm message and signals a broken stream. A msglen field cannot
be less than the dlm header size because the field is inclusive header
lengths.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Alexander Aring authored and gregkh committed May 19, 2021
1 parent ca973d2 commit ff58d1c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/dlm/midcomms.c
Expand Up @@ -49,9 +49,10 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
* cannot deliver this message to upper layers
*/
msglen = get_unaligned_le16(&hd->h_length);
if (msglen > DEFAULT_BUFFER_SIZE) {
log_print("received invalid length header: %u, will abort message parsing",
msglen);
if (msglen > DEFAULT_BUFFER_SIZE ||
msglen < sizeof(struct dlm_header)) {
log_print("received invalid length header: %u from node %d, will abort message parsing",
msglen, nodeid);
return -EBADMSG;
}

Expand Down

0 comments on commit ff58d1c

Please sign in to comment.