All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: xuehaolin@uniontech.com, aahringo@redhat.com, teigland@redhat.com
Cc: gfs2@lists.linux.dev
Subject: Re: [PATCH v2] dlm: fix out-of-bounds read triggered by short rcom messages
Date: Fri, 04 Dec 2026 02:37:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-248991@kernel.org> (raw)
In-Reply-To: <20261204021910.706512-1-xuehaolin@uniontech.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dlm: missing dlm_rcom length check in
  dlm_midcomms_receive_buffer_3_2()
--

commit 4e1720112a3b4b8b5636c0651ec522fee2cd7dfb
Author: xuehaolin <xuehaolin@uniontech.com>

dlm: fix out-of-bounds read triggered by short rcom messages

This commit restores the sizeof(struct dlm_rcom) length check in
dlm_midcomms_receive_buffer_3_1(), adds a matching check at the entry of
dlm_receive_rcom(), and rejects negative lengths in _dlm_master_lookup().

[ ... ]

> diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
> index 488a58f2c00b4..b904445be4765 100644
> --- a/fs/dlm/midcomms.c
> +++ b/fs/dlm/midcomms.c
> @@ -823,7 +823,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)) {

[Severity: High]
Should dlm_midcomms_receive_buffer_3_2() also restore this length check?

Commit 63e711b08160 ("fs: dlm: create midcomms nodes when configure")
dropped it for both versions, leaving the same stale comment before the
switch on p->rcom.rc_type in dlm_midcomms_receive_buffer_3_2().  A
16-byte DLM v3.2 DLM_RCOM message triggers a 4-byte out-of-bounds read.

A 20-byte DLM_RCOM_STATUS for an unknown lockspace also bypasses the new
guard in dlm_receive_rcom() via dlm_receive_buffer() ->
dlm_send_ls_not_ready(), which reads rc_in->rc_id and rc_in->rc_seq past
the packet and sends 16 bytes of heap memory back to the peer.

Adding the check before reading p->rcom.rc_type in
dlm_midcomms_receive_buffer_3_2() needs to jump to out so nodes_srcu is
unlocked.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204021910.706512-1-xuehaolin@uniontech.com?part=1

  reply	other threads:[~2026-12-04  2:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  7:09 [PATCH] dlm: fix out-of-bounds read triggered by short rcom messages xuehaolin
2026-12-03  7:26 ` sashiko-bot
2026-12-04  2:42   ` xuehaolin
2026-12-04  2:19 ` [PATCH v2] " xuehaolin
2026-12-04  2:37   ` sashiko-bot [this message]
2026-12-04  3:16   ` [PATCH v3] " xuehaolin
2026-12-04  3:30     ` [PATCH v2] " xuehaolin
2026-12-04  6:55     ` [PATCH v3] " xuehaolin

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=sashiko-outbox-248991@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aahringo@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=teigland@redhat.com \
    --cc=xuehaolin@uniontech.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.