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 v3] gfs2: validate log descriptor tag counts during replay
Date: Fri, 04 Dec 2026 06:57:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-249266@kernel.org> (raw)
In-Reply-To: <179636379461.1106205.14894674361180500595@skku.edu>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] gfs2: integer overflow in gfs2_struct2blk() bypasses revoke
validation
--
commit 06a5c8674445cd678fa93b7e482b13dc58aa34fa
Author: Kyuwon Cho <kyuwon.cho@skku.edu>
gfs2: validate log descriptor tag counts during replay
This commit validates metadata, journaled-data, and revoke log descriptor
counts and lengths during journal replay before the pass check.
> diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
> index 657edd406dd1c..e08d221f038c0 100644
> --- a/fs/gfs2/lops.c
> +++ b/fs/gfs2/lops.c
[ ... ]
> @@ -925,7 +930,11 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
> int first = 1;
> int error;
>
> - if (pass != 0 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_REVOKE)
> + if (be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_REVOKE)
> + return 0;
> + if (!revokes || blks != gfs2_struct2blk(sdp, revokes))
> + return -EIO;
[Severity: Medium]
Can gfs2_struct2blk() overflow when given an untrusted on-disk revokes count?
fs/gfs2/log.c:gfs2_struct2blk() {
...
if (nstruct > first) {
/* Subsequent struct gfs2_meta_header blocks */
second = sdp->sd_inptrs;
blks += DIV_ROUND_UP(nstruct - first, second);
}
...
}
Since sd_inptrs - sd_ldptrs is always 6, DIV_ROUND_UP(nstruct - first,
second) evaluates (nstruct + 5) / second in 32-bit unsigned int
arithmetic. For ld_data1 in [0xfffffffb, 0xffffffff], the numerator
wraps to 0..4 and divides to 0, so gfs2_struct2blk() returns 1.
A corrupt revoke descriptor with ld_length == 1 and ld_data1 in that
range then bypasses the validation check. Replay scans all sd_ldptrs
slots in the block into jd->jd_revoke_list because !--revokes never
reaches zero, which can suppress valid block replays in pass 1.
Using 1 + (nstruct - first - 1) / second inside the nstruct > first
branch (or 64-bit arithmetic) avoids the 32-bit overflow.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179636379461.1106205.14894674361180500595@skku.edu?part=1
prev parent reply other threads:[~2026-12-04 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:38 [PATCH v3] gfs2: validate log descriptor tag counts during replay Kyuwon Cho
2026-12-04 6:57 ` 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-249266@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.