From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.204.34.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796281980; b=F/zeuO1ZKvCS2tvWycqcSdGQXDYDVIVADsM+Vl2uWyiO23DTLHAbDCUforzoqq3czTec iidlm27Y0AeUbUM7GxaaFSLv6jSB6zej8iEH1/6avLq1viy9xq5jsLUaTSMU6aGrOuzsg uSUdSPqtz9kPpdWaPTirf5pT24OWsI6NqNY73wi+sURBusmkXWtKKIcar7Zj7mMdEzIJ+ Cx1SKm32BGzx2xV+AuqkkN252xMYI0qJmvnHfUf5LKRd1zNCI087/04dF/A8WLU3QlGKI Vo1O3bzusn+Hwf2QEuf7ZlFVQ6UM7Bep/XX9tYye1T+PbWkXWnrG+dXClcLHQuuaIwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796281980; 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:MIME-Version:Content-Type: Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO: X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=Aq9ktP7u4AjroSfToMLIzwxtJSC3pI7Ax4sL6irbdPk=; b=o38T81n9TZWlE1IjgvQuIEVV34fvUpV9NTbZEfMRgV1S9fug8kmaOmERjkOezDUgqftA 2GYk0n9QL4A2ZgplzNZNX8UHAbpwzj9D1H/K5khpL5uKyl/QMkZDjNOgDN4sBpZ2GqeUt dDOi4yIrD9XyFJyWzGjEip8PMoWMDw8igCOAILzI/nfZrjkHiShJQ325ShoggR+S69pLy 9rJD5/5NjEfVGLclMsS63ZWY64t+Av4WsGjsAqAsDEocpiWT3ydhFtsxgJ8MIJt0IhGbx 2OxtWHJXI4pJXjqRoSx7j+mptyvHor/9xb7BiEGvpSNoAp9LsdWulCLv5ymmXMExCYg== 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=bqTvGfTD; arc=none smtp.remote-ip=54.204.34.130 Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) (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 1BEEA606A322 for ; Thu, 3 Dec 2026 07:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1BEEA606A322 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=bqTvGfTD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1796281856; bh=Aq9ktP7u4AjroSfToMLIzwxtJSC3pI7Ax4sL6irbdPk=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=bqTvGfTDtDIfnMam7+7an+Mm+yz1m+zrsotoHmBCMM9KKGAdbco3SATfxJUST3B2v E1TqOLfUsLy0EzmL5uZFuOyUxYs4GLV1RCkWg0n+C7fCgWZ39NP/qCdDdZEKdSPhcs BF6XAaMNrkuOFghTY3SAdos4mcIptMuoVQDxhxPg= X-QQ-mid: zesmtpsz5t1796281748t536931e5 X-QQ-Originating-IP: IymxlIHAKxj5WQKnxFbZd4x2MSe8dih+3tyV84+XQGA= Received: from localhost.localdomain ( [124.126.19.250]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 03 Dec 2026 15:09:06 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 8553876177760803529 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] dlm: fix out-of-bounds read triggered by short rcom messages Date: Thu, 3 Dec 2026 15:09:04 +0800 Message-Id: <20261203070904.510344-1-xuehaolin@uniontech.com> X-Mailer: git-send-email 2.20.1 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=y Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpsz:uniontech.com:qybglogicsvrgz:qybglogicsvrgz6b-0 X-QQ-XMAILINFO: NOIkHYnr7Vzdsot9L/ctGn8fuUuA0jz8JOaJ/mQrFaj/GllMJ6b+Rx/N tNblJoJfApd5dWi/7Zuej/113KpgMbGfQvyPl0WyCUNWV+f53kseVjkkAXE+wDnk1ZdWoys cd41xp3WWcXgFcRrI/c9AFviWZz3+Ohfm2YPh1pbx+JeaTn5BFnyVzXam0p8grqZWqSJZ7Z kqKZt4aDolQiFA2PoVabELu3WbupueO+UBWzKoRoqxUTvj3OlBm5tAqBnxKQXm9l9bAFEKQ HTMKse+vtSujcSUHeBl+B0jxcfwKLvIDntg4I4zrMeQ6uM31zLJDoI3aP/cY3Hp7UcB7c1P zJcrRXfVeeEhv4FvDHLCfag6WmlDAgBTkXhF3q6/uHmIv+BNcr0IBrcmD0NN/U4bcsJSTzx ZtKbRgHUSs1cmV9hD7cM3pmNvCYrTcLn/YhEAg4bx8HPRc3G5bog8I3bzlRYoQb9NoYr/DS EDe+XkIF/8mFsD903iwPYqtx2/AfDNg+5dWCnAjNzxkJxqHb27bH17mdDGcbs/BFQ4VmoM/ SlKr0tbc+c16tkw/LPDrQeWCQxT476AvDq7yNq3hVD+KIkEI9fia0idj3n9DMNGQGwKH5Nz 4JAyLJTA0QyOe/OBHTdAlw4r/P40qDLhp9csxojFLKvV9GSb/0mZuPuodJg+RH5mqA3tNuB 3XCljcAdJwx5Q4YaXsl/ZFngK2MrGJYS2uEOcXoHikzw6+1TAP3Vw36oR31hSjDffah2RS5 TUNwVQQFJ3hu3+v2+5oOWvsvSbvWoerkWcg4a2bu0Ogn60omp3jxj4oYbaWnulpEk57Yu8C BuFQfjZ/ibTHVqoWMpP6p9TT4EYgaeQHdKKv0yS9t60SvSl7Fckp+oTCR6M0Bwn3L67qGVn b/2wy9BkHp93ol/Y2/iir/5xp+JV8POP4nFzaeAJSb7qCjsf5NLFxVv41WhADPVA7gLL8JZ kTOSSERku9FyggmXn4qQlec8L+cC63acPcI10B7EX4giYvzWzrn3bvxUNer11kP0zbHdvT2 4oLFkjgYCq9USMLU10+m1marK+SC47ZGHRLg0v3fxWaZbOomx/ X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== 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 adding a unified h_length >= sizeof(struct dlm_rcom) check at the top of dlm_receive_rcom(), before any type-specific dispatch. This is consistent with the existing lock_size check already performed for DLM_RCOM_LOCK and DLM_RCOM_LOCK_REPLY. All legitimate rcom messages, including those with zero-length payloads (e.g. DLM_RCOM_LOOKUP_REPLY), carry at least a full dlm_rcom header. Additionally, harden _dlm_master_lookup() in lock.c by adding a "len < 0" guard to the existing bounds check, as defense-in-depth 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: e7fd41792fc0 ("[DLM] The core of the DLM for GFS2/CLVM") Signed-off-by: xuehaolin --- fs/dlm/lock.c | 2 +- fs/dlm/rcom.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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/rcom.c b/fs/dlm/rcom.c index be1a71a6303a..b343d05f36f2 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c @@ -586,6 +586,9 @@ 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)) + goto Eshort; + switch (rc->rc_type) { case cpu_to_le32(DLM_RCOM_STATUS_REPLY): reply = 1; -- 2.43.0