mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitriy Okunev <dokunevdmitriy@gmail.com>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: lvc-project@linuxtesting.org,
	David Teigland <teigland@redhat.com>,
	Steven Whitehouse <swhiteho@redhat.com>,
	gfs2@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] gfs2: Check gfs2_metatype_check() return value in revoke_lo_scan_elements()
Date: Thu, 22 Oct 2026 14:42:36 +0300	[thread overview]
Message-ID: <20261022114236.122037-1-dokunevdmitriy@gmail.com> (raw)

revoke_lo_scan_elements() calls gfs2_metatype_check() on every log
block except the first one, but does not check its return value.
gfs2_metatype_check() verifies that the block magic and type match
GFS2_METATYPE_LB and, on mismatch, calls gfs2_withdraw(), which moves
the filesystem into a terminal state (SDF_WITHDRAWN).  The function
revoke_lo_scan_elements() keeps parsing the block as a valid
log descriptor, passes the garbage it reads to gfs2_revoke_add(),
and continues with the remaining blocks of the journal in the same
way, eventually returning 0 even though the filesystem has already
been withdrawn.

Check the return value gfs2_metatype_check() and in case of an
error bail out with -EIO.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: b3b94faa5fe5 ("[GFS2] The core of GFS2")
Signed-off-by: Dmitriy Okunev <dokunevdmitriy@gmail.com>
---
 fs/gfs2/lops.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 6dabe73ad790..2aacd3f774ab 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -936,8 +936,12 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
 		if (error)
 			return error;
 
-		if (!first)
-			gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB);
+		if (!first) {
+			if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB)) {
+				brelse(bh);
+				return -EIO;
+			}
+		}
 
 		while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
 			blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
-- 
2.53.0


                 reply	other threads:[~2026-10-22 11:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261022114236.122037-1-dokunevdmitriy@gmail.com \
    --to=dokunevdmitriy@gmail.com \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --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 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®