From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796319174; b=I5RDiJ+HLNgr83G99ulBezC0/53Xq7K8EM/iI1KB6G4rbxeMOjbLTU1RD5b02fs8dd3h /RfSEsVamhn2YQchbz+L4raQ/q4/86FAjlJg1vAU8yCfrq0MnunktRjnVB8oUF6JvMhYj dfm922ZHvjsYWqw1VX39H4js+zq/GWOvTORpc9+5C+Cr7zpm1RW2KpD1E5qJATfZHD0Wm HzvPoCFGlauMZbHr7nFA8gtxVq3cyjQA/om+Z6RPjmvVBRLWkJot2Qm2iAcraQ2nZHLso cEHS+JTP2hIcq2Bz6WseKpzJbrUXBcXtLVtiF1sGCDTFv+vz7SxieabIx1+P1WKeJPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796319174; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oLLjPvL5YGMaKyXXMO6awPOcwHK/CIYHNoNoqcpDqww=; b=QWXgG8Lo3SHLnBR9kYW14MIamo7SUrujPpljwFmvc8xjmimz/6EiocsVhsn0Vbzacz9o lFAhwaFCSOLqY3EMYCUZ3oyNhSxDdydX8NeL0LSwcAVncPxE/zkBZXvS5Lm0ykAncmMI2 0sLnerSNyAJhTSHUKSIkCKzZ+UliknKjuMwBiKdwO17fxFZflxVpHK3pTT/oPuqta9/94 87Vp+iPSv+jO8nNWAtfDGAP/+CrI7CbMWy7+o2ReOMd5mCVJrdRcaoNN+EesYNaKi+puz r6bLx4P88lyh3Kesw8DyOlq9ehioR6HgCPmf3mV770a8skAIbbsV8ELpjH01aO7Ldlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NKD/al73"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34661606A322 for ; Thu, 3 Dec 2026 17:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NKD/al73 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC4F11F000C1; Thu, 3 Dec 2026 17:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796319174; bh=oLLjPvL5YGMaKyXXMO6awPOcwHK/CIYHNoNoqcpDqww=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NKD/al73C/tCcKNb8aPE0PlnN/RSh6CsCJhRY/qseau4Oniozo2ChNWp9fHt1p35f Zy99wXTKXPQu0eZIW5WiB09M+0UJhZu6YnqQpEEEY/n1MkS/fVStNJX7JdiXuATKiv AwQ1v+9C+wWtpDulq06KpfAexDZXWjNJSjZbRQQQkzCCGoSiB34bU1yD7rpm8InD0a vs82geDM4ro9i0Rh++BOLKwDCxn9b4DSOmnc3nINhUQ5LK1BFY95tGajdYtkfYvxJV t9nA9ORe6doPJecyunTu0ThtWv4A8ULCby2yf/wKX/jXQmoM2jOcJuQDpQeWncyps3 rEPGXRJY/b6wA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] gfs2: validate log descriptor tag counts during replay Reply-To: sashiko-reviews@lists.linux.dev To: "Kyuwon Cho" , "Andreas Gruenbacher" Cc: "David Teigland" , "Steven Whitehouse" , gfs2@lists.linux.dev In-Reply-To: <179620509057.2012504.1338760759852960966@skku.edu> References: <179620509057.2012504.1338760759852960966@skku.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:32:53 +0000 X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 > 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 [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 norma= l 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, > =20 > if (pass !=3D 1 || be32_to_cpu(ld->ld_type) !=3D GFS2_LOG_DESC_METADATA) > return 0; > + if (blks > buf_limit(sdp) || > + be32_to_cpu(ld->ld_length) !=3D blks + 1) > + return -EIO; > =20 > gfs2_replay_incr_blk(jd, &start); > =20 > @@ -1000,6 +1003,7 @@ static int databuf_lo_scan_elements(struct gfs2_jde= sc *jd, u32 start, > __be64 *ptr, int pass) > { > struct gfs2_glock *gl =3D gfs2_inode_glock(jd->jd_inode); > + struct gfs2_sbd *sdp =3D GFS2_SB(jd->jd_inode); > unsigned int blks =3D 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_jde= sc *jd, u32 start, > =20 > if (pass !=3D 1 || be32_to_cpu(ld->ld_type) !=3D GFS2_LOG_DESC_JDATA) > return 0; > + if (blks > databuf_limit(sdp) || > + be32_to_cpu(ld->ld_length) !=3D 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 !=3D 1 before checking blks and ld_length. gfs2_recover_func() runs foreach_descriptor() with pass =3D 0 first, where it advances start by the unvalidated ld->ld_length right after lops_scan_elements() returns 0. With ld_length =3D=3D 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 !=3D 1 would reject malformed descriptors during pass 0 before foreach_descriptor() uses ld_length. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179620509057.201250= 4.1338760759852960966@skku.edu?part=3D1