mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Junrui Luo <moonafterrain@outlook.com>, akpm <akpm@linux-foundation.org>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@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 1/2] ocfs2/dlm: validate qr_numregions in dlm_match_regions()
Date: Wed, 18 Mar 2026 13:54:43 +0800	[thread overview]
Message-ID: <2030e53f-8826-4476-a3dc-5bf2c24e1e4d@linux.alibaba.com> (raw)
In-Reply-To: <SYBPR01MB788166F524AD04E262E174BEAF7BA@SYBPR01MB7881.ausprd01.prod.outlook.com>



On 3/7/26 3:21 PM, Junrui Luo wrote:
> The qr_numregions field from a DLM_QUERY_REGION network message is used
> directly as loop bounds in dlm_match_regions() without checking against
> O2NM_MAX_REGIONS. Since qr_regions is sized for at most O2NM_MAX_REGIONS
> (32) entries, a crafted message with qr_numregions > 32 causes
> out-of-bounds reads past the qr_regions buffer.
> 
> Add a bounds check for qr_numregions before entering the loops.
> 
> Fixes: ea2034416b54 ("ocfs2/dlm: Add message DLM_QUERY_REGION")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>

Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/dlm/dlmdomain.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
> index 70ca79e4bdc3..0a28cb5ded2a 100644
> --- a/fs/ocfs2/dlm/dlmdomain.c
> +++ b/fs/ocfs2/dlm/dlmdomain.c
> @@ -980,6 +980,14 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,
>  		goto bail;
>  	}
>  
> +	if (qr->qr_numregions > O2NM_MAX_REGIONS) {
> +		mlog(ML_ERROR, "Domain %s: Joining node %d has invalid "
> +		     "number of heartbeat regions %u\n",
> +		     qr->qr_domain, qr->qr_node, qr->qr_numregions);
> +		status = -EINVAL;
> +		goto bail;
> +	}
> +
>  	r = remote;
>  	for (i = 0; i < qr->qr_numregions; ++i) {
>  		mlog(0, "Region %.*s\n", O2HB_MAX_REGION_NAME_LEN, r);
> 


  reply	other threads:[~2026-03-18  5:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07  7:22 [PATCH 0/2] ocfs2/dlm: fix two bugs " Junrui Luo
2026-03-07  7:21 ` [PATCH 1/2] ocfs2/dlm: validate qr_numregions " Junrui Luo
2026-03-18  5:54   ` Joseph Qi [this message]
2026-03-07  7:21 ` [PATCH 2/2] ocfs2/dlm: fix off-by-one in dlm_match_regions() region comparison Junrui Luo
2026-03-18  5:55   ` Joseph Qi
2026-03-07 16:06 ` [PATCH 0/2] ocfs2/dlm: fix two bugs in dlm_match_regions() Wengang Wang
2026-03-07 16:14   ` Wengang Wang
2026-03-09  1:26   ` Joseph Qi

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=2030e53f-8826-4476-a3dc-5bf2c24e1e4d@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --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=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®