From: Alexander Aring Date: Mon, 1 Mar 2021 22:05:17 +0000 (-0500) Subject: fs: dlm: check on minimum msglen size X-Git-Tag: accepted/tizen/unified/20230118.172025~7321^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=710176e8363f269c6ecd73d203973b31ace119d3;p=platform%2Fkernel%2Flinux-rpi.git fs: dlm: check on minimum msglen size 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 Signed-off-by: David Teigland --- diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index fde3a6a..0bedfa8 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -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; }