From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.207.19.206 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354323; b=kqOVXa6zKEyn6AKH6NCr7ijIDMeIMmLuE2CZKFR7cwPMW1zVcwSmiRUxX5Vr6NkQaPUW UrzNp6hI2B8fCwFSv28ahUwPHBmCHl1EGo0wearhEjMOIY1/7TcukoxFQ0I8a/L9/3jRg cYA21FpuSeHJdHVhUPWIwG+S6xGGgzwLr/8Igj9eM0aa+GJG34/jY/7oKMXMZ9UAMdRer ZBL4CknfWzdtmEbuV+d5RyJjnnoNlZw1SfrprMHRtwV2hvOas0Qb9b0cA1WBV+thLcD2Y mHbC5hIb6LjKEaJV8k3T2HDcXWrnbS1vWhFUkPyta0vag8fPdsf0IBBYEDROH8JJTXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354323; h=DMARC-Filter:DKIM-Signature:X-QQ-mid:X-QQ-Originating-IP:Received: X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=VF2S2bWX8T5ZEAifkkDf1y1JXWJYzBUKdbx7xC9hEqI=; b=AHKAWdi/BWois9cHzqRy7FQ9OexV5IsTEzBNUKthc2iqgAk4jYKGBXeYvvZIC/S787Uk KRFo5lN2INbRQLwN/rDwRZWJeD2GCu1gSqTs+g8RM75Oe6fhdTY+4LSfXOdUh7uVqqSla dHU6LP3YzmBGbdE1CrNjcpBVwxUWe6NUJZsuam5ArbYXQwzl9ZsrqlupV8pxGhlyNLqf8 YT9eYFsrEc787vlqj/OBv5m+xtNyAKu6R0gcuuP2v2at8z9UO1NnB+1+qmYJxx/lNRypj EuNQwoN85EGs8vBQBMARkajwEUl/n/WUuE376AtuH0claYYC0f3z/DqleRcjue6V3rg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=YrvLJprI; arc=none smtp.remote-ip=54.207.19.206 Received: from smtpbgbr1.qq.com (smtpbgbr1.qq.com [54.207.19.206]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB44606A32D for ; Fri, 4 Dec 2026 03:18:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7CB44606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=YrvLJprI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1796354292; bh=VF2S2bWX8T5ZEAifkkDf1y1JXWJYzBUKdbx7xC9hEqI=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=YrvLJprI5hXIgjrgNsrPCwiHaU9y2GDdP6ZhhZCNKwTx95Gq+rNGi5NvitmX0SPR7 n1PxhoqExDEwteuG2K/fRdWGSN2EBJC6cTpw7DvoPIelHlrs90Ghnw+Vl14ZQZfKca bQwOtVgnKNwb5MKkyrTIRvHS6DX4zqxr4iDcpsZY= X-QQ-mid: esmtpgz10t1796354174t8a8470eb X-QQ-Originating-IP: kzoy+lokdV/U8GqtU3VMVkYQSTr9auHqZiqtCvr/cR4= Received: from localhost.localdomain ( [1.202.39.170]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 04 Dec 2026 11:16:12 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 7318438507993101653 EX-QQ-RecipientCnt: 5 From: xuehaolin@uniontech.com To: aahringo@redhat.com, teigland@redhat.com Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, xuehaolin Subject: [PATCH v3] dlm: fix out-of-bounds read triggered by short rcom messages Date: Fri, 4 Dec 2026 11:16:08 +0800 Message-Id: <20261204031608.719430-1-xuehaolin@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20261204021910.706512-1-xuehaolin@uniontech.com> References: <20261204021910.706512-1-xuehaolin@uniontech.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: esmtpgz:uniontech.com:qybglogicsvrgz:qybglogicsvrgz6b-0 X-QQ-XMAILINFO: MOE+vapm9804An7gPgPK/kXUZPanAlNleHCue1+M7omEhE5m3br4Yv7E yU0K7h7vZZkETs1ynRsLxw6XDk9PADhHuA8824PJc6FZc8POj8vMXt0UbVYMTMAsl1l1uFh VL53QJ6dGXGdMXKDCq38NiYFvHEd2vRbekn4hI9jpAhTX8SZMvgHIhQwU2pA0rPWf0XGTCC +7llB0KkpCDBOHXjGBY7rBhsVJIFQMy8l57yeRBuHVbCzGWOOTOUjQVASQ0M5FQmJsrgzjf HN6w9jdBQ+9hqklBTOWCACPPFWaiKWnL0uIJi3lYP4dQJ7HGh1LvS9hP/EjdGLJHtFhi1Oo k9eWa7Hox9CUQfwLFBk3uz+y2NvRP5060EWm+ZfK2IQXeC4xCFSB5jdEFzwmf3TcYv3earE yIh6bYnVaszP+t4ziNKJtC5dNGM+2FN+8rq/8VyiPdAHb5h7df3LjfglPqJa9J5yi6PM35X J0VuBZx0Wt7Xld00d7C2v2ZIK7q+BUL6a2I7vulHiuBA5fRGiXomD70RFQjCShLKnMZFSRg qklKk/rmdhtAuUI6Q+a3UXc1POGTUq7mPtnJkgBmxdzOrEIhw/UPpdZlyVpQCTaS4+jY/UG 6K9pvU9QNumQmnAWzi0KiDwU0FsPZZqC/WP6w7HnvBgGhpelqPwFWrWpN0ntjDQerLHtAqy xzyH72HxDsUhIPjMw5rwKt7WRxOsAwodK/Obgeq8nHQqR/UFHMROGh/iyY5TXGkLXbH0z8n 3Lgn7r7f6mHxnVCXmz3V2i4WCZA5/fNVJ5PuyrGgzvXaj06yVFw0+uWqUhaSgmU9skQKyeW I87QksYagCddLaYXrQviU6kzKpC//YlwhoGb94PZaOXRZ9Bap+KOflUkGAQhLLaYod30uFc D0hsNQmZhqXmApGB5nvoz15ctPExliRY6UL0hcNzpblUUJxHS5P3gD4E6B/HqBcNyNdubF1 /AWGMRc49UUb/w5Dnf5CP3ljV5JuZU84kLVF3hshY+NGF+ecS5K7l76wbv9FpTGN+72yt3e RqX9HxBw2ndgr/963/rXMvjHqsiG5osCJHzKCzCJnBkOFYSEgozxmlJXsN1Jk= X-QQ-XMRINFO: Mp0Kj//9VHAxzExpfF+O8yhSrljjwrznVg== X-QQ-RECHKSPAM: 0 From: xuehaolin The dlm_validate_incoming_buffer() in midcomms.c only checks that received messages are at least sizeof(struct dlm_header) (16 bytes). It does not verify that rcom messages meet the sizeof(struct dlm_rcom) (48 bytes) minimum. A malicious cluster member can send a DLM_RCOM_LOOKUP or DLM_RCOM_NAMES message with h_length set to 16, causing the payload length calculation in receive_rcom_lookup() / receive_rcom_names(): len = le16_to_cpu(rc_in->rc_header.h_length) - sizeof(struct dlm_rcom); to produce a negative value (16 - 48 = -32). In the LOOKUP path, the negative len is passed to dlm_master_lookup() -> _dlm_master_lookup(), where the signed comparison "len > DLM_RESNAME_MAXLEN" (-32 > 64) evaluates to false, allowing the negative length to reach jhash(name, len, 0); promoted to unsigned for jhash it becomes approximately 4 GB, triggering an out-of-bounds read and kernel oops/panic (CWE-125, remote DoS). In the NAMES path, the negative inlen reaches dlm_copy_master_names(), where the signed "inlen > 1" check misroutes it — a logic bug rather than an out-of-bounds access. Fix this by restoring the sizeof(struct dlm_rcom) length check in dlm_midcomms_receive_buffer_3_1() and adding it to the DLM_RCOM case of dlm_midcomms_receive_buffer_3_2() before the rcom type is read: the DLM_MSG case validates its message size, but the DLM_RCOM cases lost this check when the midcomms receive path was restructured, leaving only a stale "length already checked" comment. Without it, short rcom messages reach dlm_receive_buffer() and the recovery layer, where fields beyond the validated header are read and, in the lockspace not-ready path, echoed back to the peer. Additionally, guard the entry of dlm_receive_rcom() with the same check as defense-in-depth covering all rcom entry paths, using a rejection log that references only the validated header fields, and harden _dlm_master_lookup() in lock.c by adding a "len < 0" guard to the existing bounds check, in case other call paths bypass the rcom dispatch validation. Found by an internal automated security research pipeline (static analysis scan with automated triage and audit). The fix was drafted within the same pipeline and is submitted after review by the human signer. Reproduction was confirmed on a test VM with a kernel module demonstrating the out-of-bounds read. Fixes: 63e711b08160 ("fs: dlm: create midcomms nodes when configure") Signed-off-by: xuehaolin --- fs/dlm/lock.c | 2 +- fs/dlm/midcomms.c | 15 ++++++++++++--- fs/dlm/rcom.c | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-) Changes in v3: - also restore the sizeof(struct dlm_rcom) check in the DLM_RCOM case of dlm_midcomms_receive_buffer_3_2(): 63e711b08160 dropped the check for both protocol versions, and a short 3.2 rcom message reaches the same stale-commented rc_type read; it can also reach the lockspace not-ready path in dlm_send_ls_not_ready(), which reads rc_id/rc_seq past the packet and echoes them back to the peer - drop the stale "length already checked" comment it replaced Changes in v2: - restore the sizeof(struct dlm_rcom) length check in dlm_midcomms_receive_buffer_3_1(); the DLM_MSG case kept its check when the midcomms receive path was restructured, the DLM_RCOM case lost it, leaving a stale "length already checked" comment - stop dereferencing rc->rc_type in the short-message rejection path of dlm_receive_rcom(); the guard now logs the validated h_length only, since rc_type sits beyond the 16 bytes that dlm_validate_incoming_buffer() guarantees - point Fixes at 63e711b08160, the commit that dropped the midcomms length check, instead of the original DLM import diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index c715e171bab7..56ec68e28f93 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -1270,7 +1270,7 @@ static int _dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *na int our_nodeid = dlm_our_nodeid(); int dir_nodeid, error; - if (len > DLM_RESNAME_MAXLEN) + if (len < 0 || len > DLM_RESNAME_MAXLEN) return -EINVAL; if (from_nodeid == our_nodeid) { diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index 045431524494..bc52c43b0700 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -700,9 +700,13 @@ static void dlm_midcomms_receive_buffer_3_2(const union dlm_packet *p, int nodei /* these rcom message we use to determine version. * they have their own retransmission handling and * are the first messages of dlm. - * - * length already checked. */ + if (msglen < sizeof(struct dlm_rcom)) { + log_print("rcom msg too small: %u, will skip this message from node %d", + msglen, nodeid); + goto out; + } + switch (p->rcom.rc_type) { case cpu_to_le32(DLM_RCOM_NAMES): fallthrough; @@ -815,7 +819,12 @@ static void dlm_midcomms_receive_buffer_3_1(const union dlm_packet *p, int nodei switch (p->header.h_cmd) { case DLM_RCOM: - /* length already checked */ + if (msglen < sizeof(struct dlm_rcom)) { + log_print("rcom msg too small: %u, will skip this message from node %d", + msglen, nodeid); + return; + } + break; case DLM_MSG: if (msglen < sizeof(struct dlm_message)) { diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index be1a71a6303a..fe23b92a3faf 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c @@ -586,6 +586,12 @@ void dlm_receive_rcom(struct dlm_ls *ls, const struct dlm_rcom *rc, int nodeid) uint32_t status; uint64_t seq; + if (le16_to_cpu(rc->rc_header.h_length) < sizeof(struct dlm_rcom)) { + log_error(ls, "rcom message from %d is too short (%u bytes)", + nodeid, le16_to_cpu(rc->rc_header.h_length)); + return; + } + switch (rc->rc_type) { case cpu_to_le32(DLM_RCOM_STATUS_REPLY): reply = 1; -- 2.43.0