cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH AUTOSEL 5.11 008/104] fs: dlm: check on minimum msglen size
Date: Wed,  5 May 2021 12:32:37 -0400	[thread overview]
Message-ID: <20210505163413.3461611-8-sashal@kernel.org> (raw)
In-Reply-To: <20210505163413.3461611-1-sashal@kernel.org>

From: Alexander Aring <aahringo@redhat.com>

[ Upstream commit 710176e8363f269c6ecd73d203973b31ace119d3 ]

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>
---
 fs/dlm/midcomms.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index fde3a6afe4be..0bedfa8606a2 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;
 		}
 
-- 
2.30.2




  parent reply	other threads:[~2021-05-05 16:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210505163413.3461611-1-sashal@kernel.org>
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 003/104] fs: dlm: fix debugfs dump Sasha Levin
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 004/104] fs: dlm: fix mark setting deadlock Sasha Levin
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 005/104] fs: dlm: add errno handling to check callback Sasha Levin
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 006/104] fs: dlm: add check if dlm is currently running Sasha Levin
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 007/104] fs: dlm: change allocation limits Sasha Levin
2021-05-05 16:32 ` Sasha Levin [this message]
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 009/104] fs: dlm: flush swork on shutdown Sasha Levin
2021-05-05 16:32 ` [Cluster-devel] [PATCH AUTOSEL 5.11 010/104] fs: dlm: add shutdown hook Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505163413.3461611-8-sashal@kernel.org \
    --to=sashal@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).