From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.254.200.128 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796350951; b=jX8Lu7sSqE1d3/Bt3sJBX1UaIe1/MtwZnzFkWdaXJbNUXRsj8NqLf5LqatlDbbI829MR 4rVnlXeu06iIb8wJEeZmMFbtriPw6m+g/7gn6sREHCQ17ZaqEt+DpvO+C80tTbdVk699R wAwLlFS7RkFET1p0oB7PVipHLCNHEsQfhIZQGXZH5qX7ZUsr1zX2kPCK9Ky8xOP23dnc+ TBBx0yu1gDb8hCZ6Lt6FTG4BT/8Es135IBfdkPuhh5k7cj+WC5NxUzN/UOX3mQUWygz/b U+cItIwIAWq+WxKYnojthuRMom6dZsHdse1Dh67t3HCGR7ch8eB0IVE3fMiSDK8rfTw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796350951; 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=WMYCsfOI2dtKU3JIuP2ZDG1htIY/3tPgcOioj3iG/i4=; b=FSheW7U34hlYppmn57k4hcTo+IcRWbFhbr9LBhi/uyL5gUs1ONRufFevEWBaSa+AkjvO z7BQpbZrfh/4Drwpf/tQELERnD1kTKKX2BKr4j+YMwaO/K/HlQ1raO8IABI5PWenMoTUz MMQfRtRi/0j6P4gZ77QWm69jYzIa13noZVuqGsA6Fkp9dRT6HPDD9GJhsV0Ec+ED6KTwW 23cGnL5awe3b0JdWqHIUtH4rt6qNTx9iTT6jNAorSG/jreC5n4cuB3jubCabFc5npLXMq 2rhj5owMOwx3pCkCw8I2Yai+i9EGoRB74+PD8MHnSix1SETgF6w6hxSMK/oUSvtV4sA== 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=PZv9R1Ze; arc=none smtp.remote-ip=54.254.200.128 Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) (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 2251D606A322 for ; Fri, 4 Dec 2026 02:22:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2251D606A322 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=PZv9R1Ze DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1796350863; bh=WMYCsfOI2dtKU3JIuP2ZDG1htIY/3tPgcOioj3iG/i4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=PZv9R1Ze8ySqngQeCDNSpVApCnKgd7+yJalSzm7mENX23bGhDdv4ExHeq9KFkbsXZ pluLXI0+31NNA3JDSW6NBLrd55LiM5WE0usL0N5DsHb1JwheHY1oDIJJIlK/ld+HvZ HLhJYAGA14GSqfLvs/JHm8KLJ3Zoi6d5VOmP7WhE= X-QQ-mid: esmtpgz16t1796350754t3b82db19 X-QQ-Originating-IP: ePhxSQnZYv5xzlB/on4zKeN4ENaSAUi7F81LYKIOJts= Received: from localhost.localdomain ( [124.126.19.250]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 04 Dec 2026 10:19:12 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 10576052492567576062 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 v2] dlm: fix out-of-bounds read triggered by short rcom messages Date: Fri, 4 Dec 2026 10:19:10 +0800 Message-Id: <20261204021910.706512-1-xuehaolin@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20261203070904.510344-1-xuehaolin@uniontech.com> References: <20261203070904.510344-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: OKkKo7I1HxIeQw6VYceDSDKGW5gxBmt+8FA7skCGMqPr1kotwuhajU1T WK0yw+Vr3fek6EFKSoeRIBAqbihVJSQ8+q5Wpq8/rYAxmP/EreXwVBTXNNoU7xB18ZxFKPn Ku8W6NlHZ9Q0O3it4Gzeex0v6NX7TKhGugoX4S9yGVitqEofpbw/aoAp0EC0PmtpdkFhU4A clztO7tu6RnutYrRKG48WPx1ygQRO54UksE/IooUfIcZrOFocPoFaAglmT1NrcZYIG5QU45 KxhlJ4iXbtqOtyZTW5OXLeKu8c+Oz53h2vFhqXVuNGR2cz2o0RppxTDu26z+efjPZ9Kwfmw U1jpPF2/UfxkULk55vT9UW7pkRORvBK4n7dH95XPFqch0SisWSnwmPBNHsLQJTIdEQR0MCX ofH6OWAvaWaPLTK2fl/zuTnCoSdH5JmDdCvOegRvs3nZFiVJHo8N/glLksCPjG7rlyEsK/U T+FTL39rTE9Tuc66Z/5Pv9IPpER1LJKaxDD0olGlDIR5G3ar4lOXBXjpg7XpkUXb2yOg3Jt df0eY8CT2uP5WefdHXYlM4e7d4lMNjuAlQL9YhQnYPTZ2VKDFtnNr/m1cceEFBNpmGrkJgE aycGWWXKr7hpwhRqfTBpBJQs4wgXKN7jSUFXEv0ueVUepU0H/lXim+Ode4SPfiTmUL6zB0Y AqxeENKZU4jCEur9zLI1e3CAIzdXnhy7dzYNNVfyd0o3Sanao4p7UpjTBZb8d1m/dUG0aLh fFxYXdDBGQ9rlovIRwlhrecLN8OQ8Z3L5GatUECJB4QgAPOfZwu0bKdY1qmbtM2Zk2TZdMJ ErImbc1u100RKE2C0Omf8MVbd3elQR/09sopWuGpMLUoyMlwJiEictgvCVVgIFlEVVS/rne UYdGWgwLOulAdqnNplpE9bDb01KRp8Pi6eZn9ZAbgK2ccbicF0qjazARQt4bRJapjL0KR/5 arq4R3LJ2ALWqcxrt5Ntys3OUVTWBNjBdHjrKYp+wHEW5A5CU73fqyAUWAoRRSf9HORKtBc N9yzvxgq7Xkzek0ZixVzz5CYM2WDdVTWfx414qpA== X-QQ-XMRINFO: NI4Ajvh11aEjEMj13RCX7UuhPEoou2bs1g== 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() before the message is handed to the recovery layer: the DLM_MSG case validates its message size, but the DLM_RCOM case lost this check when the midcomms receive path was restructured, leaving only a stale "length already checked" comment. 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 | 7 ++++++- fs/dlm/rcom.c | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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..495b2517ef7e 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -815,7 +815,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