All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kyuwon Cho" <kyuwon.cho@skku.edu>,
	"Andreas Gruenbacher" <agruenba@redhat.com>
Cc: "David Teigland" <teigland@redhat.com>,
	"Steven Whitehouse" <swhiteho@redhat.com>,
	gfs2@lists.linux.dev
Subject: Re: [PATCH] gfs2: validate log descriptor tag counts during replay
Date: Thu, 03 Dec 2026 17:32:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-248265@kernel.org> (raw)
In-Reply-To: <179620509057.2012504.1338760759852960966@skku.edu>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] gfs2: pass-0 bypass of ld_length checks in
  buf/databuf_lo_scan_elements()
- [Low] gfs2: missing Fixes trailer for databuf_lo_scan_elements()
  introduction
--

commit b9181f77fc6ab1c6472787275e362b8ec88cc766
Author: Kyuwon Cho <kyuwon.cho@skku.edu>

> gfs2: validate log descriptor tag counts during replay
>
> Journal replay trusts ld_data1 as the number of metadata or
> journaled-data tags stored after a log descriptor. A corrupt journal can
> advertise more tags than fit in the descriptor block, making the replay
> scanners read beyond the buffer.
>
> Check the format-specific tag capacity and require ld_length to account
> for exactly the descriptor and its payload blocks. Reject malformed
> descriptors before scanning their tags.
>
> Fixes: b3b94faa5fe5 ("[GFS2] The core of GFS2")
> Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>

[Severity: Low]
Since this also fixes missing validation in databuf_lo_scan_elements(),
which was added later than b3b94faa5fe5 ("[GFS2] The core of GFS2"),
should this also include:

  Fixes: 18ec7d5c3f43 ("[GFS2] Make journaled data files identical to normal files on disk")

> diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
> index 657edd406dd1c..57220afac0912 100644
> --- a/fs/gfs2/lops.c
> +++ b/fs/gfs2/lops.c
> @@ -792,6 +792,9 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
>  
>  	if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA)
>  		return 0;
> +	if (blks > buf_limit(sdp) ||
> +	    be32_to_cpu(ld->ld_length) != blks + 1)
> +		return -EIO;
>  
>  	gfs2_replay_incr_blk(jd, &start);
>  
> @@ -1000,6 +1003,7 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
>  				    __be64 *ptr, int pass)
>  {
>  	struct gfs2_glock *gl = gfs2_inode_glock(jd->jd_inode);
> +	struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
>  	unsigned int blks = be32_to_cpu(ld->ld_data1);
>  	struct buffer_head *bh_log, *bh_ip;
>  	u64 blkno;
> @@ -1008,6 +1012,9 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
>  
>  	if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA)
>  		return 0;
> +	if (blks > databuf_limit(sdp) ||
> +	    be32_to_cpu(ld->ld_length) != blks + 1)
> +		return -EIO;

[Severity: Medium]
Can a malformed descriptor bypass the new ld_length check during pass 0?

Both buf_lo_scan_elements() and databuf_lo_scan_elements() return 0 on
pass != 1 before checking blks and ld_length.  gfs2_recover_func() runs
foreach_descriptor() with pass = 0 first, where it advances start by the
unvalidated ld->ld_length right after lops_scan_elements() returns 0.

With ld_length == 0 on a corrupt metadata or journaled-data descriptor,
foreach_descriptor() never advances start and loops forever while holding
sdp->sd_freeze_mutex, sdp->sd_log_flush_lock, and JDF_RECOVERY, hanging
mount and unmount.

Checking ld_type first, validating blks and ld_length, and only then
returning 0 when pass != 1 would reject malformed descriptors during
pass 0 before foreach_descriptor() uses ld_length.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179620509057.2012504.1338760759852960966@skku.edu?part=1

      reply	other threads:[~2026-12-03 17:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:46 [PATCH] gfs2: validate log descriptor tag counts during replay Kyuwon Cho
2026-12-03 17:32 ` sashiko-bot [this message]

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-248265@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=kyuwon.cho@skku.edu \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=swhiteho@redhat.com \
    --cc=teigland@redhat.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.