From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Junrui Luo <moonafterrain@outlook.com>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Yuhao Jiang <danisjiang@gmail.com>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Sunil Mushran <sunil.mushran@oracle.com>
Subject: Re: [PATCH] ocfs2/dlm: validate message payload length in query handlers
Date: Tue, 17 Mar 2026 20:22:08 +0800 [thread overview]
Message-ID: <a7f7510b-652c-414b-a530-3aeda945c74a@linux.alibaba.com> (raw)
In-Reply-To: <SYBPR01MB7881890B57945C79BC03F31EAF44A@SYBPR01MB7881.ausprd01.prod.outlook.com>
On 3/12/26 6:03 PM, Junrui Luo wrote:
> dlm_query_region_handler() and dlm_query_nodeinfo_handler() cast
> msg->buf to their respective structure pointers without validating
> that the received message length is sufficient. The o2net transport
> layer only enforces a maximum payload length, not a minimum, so a
> truncated message passes the network check and reaches the handler.
>
> This causes out-of-bounds reads from the receive page buffer when
> accessing structure fields beyond the actual payload, leading to
> operations on stale or uninitialized data.
>
OCFS2 is always deployed in trusted network.
So if not considering defensive programming, how does it happen in real
environment?
Thanks,
Joseph
> Fix by validating that len covers the full expected structure size
> before accessing any payload fields.
>
> Cc: stable@vger.kernel.org
> Fixes: ea2034416b54 ("ocfs2/dlm: Add message DLM_QUERY_REGION")
> Fixes: 18cfdf1b1a8e ("ocfs2/dlm: Add message DLM_QUERY_NODEINFO")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
> ---
> fs/ocfs2/dlm/dlmdomain.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
> index 70ca79e4bdc3..07aef9ae8cbe 100644
> --- a/fs/ocfs2/dlm/dlmdomain.c
> +++ b/fs/ocfs2/dlm/dlmdomain.c
> @@ -1100,6 +1100,9 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len,
> char *local = NULL;
> int status = 0;
>
> + if (len < sizeof(struct o2net_msg) + sizeof(struct dlm_query_region))
> + return -EINVAL;
> +
> qr = (struct dlm_query_region *) msg->buf;
>
> mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node,
> @@ -1276,6 +1279,9 @@ static int dlm_query_nodeinfo_handler(struct o2net_msg *msg, u32 len,
> struct dlm_ctxt *dlm = NULL;
> int status = -EINVAL;
>
> + if (len < sizeof(struct o2net_msg) + sizeof(struct dlm_query_nodeinfo))
> + return -EINVAL;
> +
> qn = (struct dlm_query_nodeinfo *) msg->buf;
>
> mlog(0, "Node %u queries nodes on domain %s\n", qn->qn_nodenum,
>
> ---
> base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681
> change-id: 20260312-fixes-c80f56fb6069
>
> Best regards,
next prev parent reply other threads:[~2026-03-17 12:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 10:03 Junrui Luo
2026-03-17 12:22 ` Joseph Qi [this message]
2026-03-18 5:17 ` Junrui Luo
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=a7f7510b-652c-414b-a530-3aeda945c74a@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=danisjiang@gmail.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=moonafterrain@outlook.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=sunil.mushran@oracle.com \
/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
all inboxes | Powered by JetHome®