From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796282797; b=TzbU59p4cqhse3Gk5HXCMAPXDNlw5erJp9kVZ0fUX1aoNz05hsV9mgBrBJHY4iavqCo6 3WRuWwUfBgpoOiECPsVeJ0Vy7Ag+LAzpY+0exeF9XpWs2dYhPlfWwk9079ZvlFJfVMG+h oSCZKTI+S/0M8bKU4xtkD/46lWAyDIdYRb9QAHScqpgBXeO4qQophkRB0lXo+rDp3vzOG siKRcr6lsCKYdf6WDmdn9Zvh2OjYr4SxiDZcBYDweGhq6zOLhbmzuERbkjocVS3OmQFas br9sk6lKhT1kU2QIGzUQ4Hryx4R36gJihEt4VsvfZ0VieQLc16WfHpDzBu/7J2dYLCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796282797; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=nc6qRlrpzGXFGb9wgwVFftC5wBWmJswxzwLkwGqgIrU=; b=vVa87HYzcIrMCD5nM5RMqbSHHBf2Qc+ZB6w2GkQA3Xejpbdb+nfysCLEXtjMbPAE9U0W utl5u40dYH0fn2ctECt6j5r9Uo7HHv9ylHXxVMFCkY+vP8AD9dintbccRge4qCjsWJZ4h ZqIa33gfbas5I5zCgmgy7EfLXoorxSmqXYF0ERq5Q2OqhNyNZHXP5IWaF4O3Kg0xT2i0v fdE8ibg8Vj6hXkvSSNuo0KbB4HtL2pP+nl6+KJJeVfARt8h79sQtWkH1o3jcTkZUY0KLZ xMXQaUdedUEuxYxwMpDncN+Ez0IrcEmpefP0crU8TM/N/RuGrXHh8jIInToNB+3L33A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JDoYu4pd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C2D3606A32C for ; Thu, 3 Dec 2026 07:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JDoYu4pd Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD06B1F000C1; Thu, 3 Dec 2026 07:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796282797; bh=nc6qRlrpzGXFGb9wgwVFftC5wBWmJswxzwLkwGqgIrU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JDoYu4pdr6iq9yx0naVsSowZ0mnoLf15OzR1NpZkkvXefQfICIdItAA8ySsj7gas/ 9MWKhE7ovc1HcgFWTa4k0OzXOHen0LyGl6wgVGENvGD+UKkeMQNvUbJ1bN/RLixHLe JjwZmlnQt3LOVJeFfpNPqzHM0zxqUbtyhvGp/8+dAhO9iWymTlfvl2av0/lbR1pw2f fn5EU5qoifln8OQ4m7/Krt3UWuF+5CFW6+P83cyypKwqEOrnC7yayDMIRXZOr7Rk44 nuT5dSfzWXHEOfoAWphQ9+9MJ2XGKFKnwWc7AZEDpDP5WHfu1EI/SX8GR49RGIfKt/ UA6fcnAl4HLzg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] dlm: fix out-of-bounds read triggered by short rcom messages Reply-To: sashiko-reviews@lists.linux.dev To: xuehaolin@uniontech.com, aahringo@redhat.com, teigland@redhat.com Cc: gfs2@lists.linux.dev In-Reply-To: <20261203070904.510344-1-xuehaolin@uniontech.com> References: <20261203070904.510344-1-xuehaolin@uniontech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:26:36 +0000 X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] dlm: out-of-bounds read of rc_type at Eshort in dlm_receive_rcom() - [Low] dlm: Fixes trailer cites e7fd41792fc0 instead of regression 63e711b08160 -- commit e82cd5421775cac9af6a548cb1ceb3404125aed1 Author: xuehaolin > dlm: fix out-of-bounds read triggered by short rcom messages > > 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 =3D le16_to_cpu(rc_in->rc_header.h_length) - sizeof(struct dlm_rcom= ); > > to produce a negative value (16 - 48 =3D -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 =E2=80=94 a logic bug rather than an out-of-bounds acc= ess. > > Fix this by adding a unified h_length >=3D 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 [Severity: Low] Should the Fixes tag cite 63e711b08160 ("fs: dlm: create midcomms nodes when configure") instead? The sizeof(struct dlm_rcom) check was added to fs/dlm/midcomms.c in eef7d739c218 ("dlm: dlm_process_incoming_buffer() fixes") and dropped when 63e711b08160 ("fs: dlm: create midcomms nodes when configure") removed dlm_midcomms_recv_node_lookup(). Citing the initial import misdirects stable backports to older branches that already reject short rcom messages. [ ... ] > diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c > index be1a71a6303af..b343d05f36f23 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; > =20 > + 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 =3D 1; [Severity: High] Does jumping to Eshort here cause an out-of-bounds read of rc->rc_type? fs/dlm/rcom.c:dlm_receive_rcom() { ... Eshort: log_error(ls, "recovery message %d from %d is too short", le32_to_cpu(rc->rc_type), nodeid); } rc_type sits at bytes 16..19 immediately after the 16-byte struct dlm_header. When a cluster peer sends a 16-byte rcom message at the end of the kmalloc() buffer allocated by new_processqueue_entry(), Eshort performs a 4-byte slab out-of-bounds read. Logging the error without dereferencing rc->rc_type (or rejecting short rcom messages in midcomms.c before reaching dlm_receive_rcom()) would avoid the out-of-bounds access. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070904.5103= 44-1-xuehaolin@uniontech.com?part=3D1