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=1796058595; b=q+YRFYm160ogyZxFpb09FfTu+ShemQZ6yTFHFYSV6CgTNwBKCKZg6DHgG8G8vcV61LcM /HPiQg+PFpWg3ZF29N1MLB7H1KKzGDj43xIwm1D0sqj71Uu6pPZd6vpgdB8BT97EExMbD 1u2IXK1DLDqDNEvoMxf/E/BTJTTfptend+faxT8G/5w7OhH7TGQO/XeXGDPShNbjP2aqV ubEZFqBE9qrvFFJljT396IJOSw+w0bZYmDnUL+7fr8b1obX05p5M/yU3lumbwuhONNSw6 HGbjhdNh+3IVCsaJ5MfcMStenA0ubiJMtNE+MYV4UUTn4IhBNxJd1Cn7ZgiUnyEG5kA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796058595; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=E6ELrhAvMj7YrNoRerksTt5Tbs2Lt8mHPWpjbCHz3Xk=; b=pmLAQoRI3RYO+M8b4ijgxTBlLcrjJoCEVkrWLuNyXy+6Wmt3QoDiOVvV2YhwDuGAcxGS wXc8CJhgJx5wB2Gaqz3hkLiI5nW92x9LWT81VYKR/as2qWd5M3sZBNLcLQ/9EbCzH9vm2 7vFIVWHQ+zlMbGPZD5cUZPg6PcworCjCfYDi560i7CFAB3S74kie8E9KdF6QKwXjmdTYf Gna/0p1niY14ff1Yp/kaI4ru2y7uSx/fmZnrmR1bJ2Ihm0RphY0atCT5/mfaBXcCwVm57 UIgYnhEdT28s2Kfuybx6y6u2HgSAf/9GL1zqbpbsq0uBOnVXvtAra9vRdlEWmJ0jI2A== 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=bf7sEmTj; 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 64A58606A331 for ; Mon, 30 Nov 2026 17:09:55 +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=bf7sEmTj Received: by smtp.kernel.org (Postfix) with ESMTPSA id D84911F0089C; Mon, 30 Nov 2026 17:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796058595; bh=E6ELrhAvMj7YrNoRerksTt5Tbs2Lt8mHPWpjbCHz3Xk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bf7sEmTjmDDz8reLDXEa8x2VO6l6llclJK6lUaZO1FILUd3MDiQ0fKobm24HtPDom 35c3LO/+/X4+1pr0Kkohil8SIxPz/lrNXt9Kem+PLVEJouuyPXrfE2GrLGliA057xQ 1t3yxKYDQCncPISAj9D3q/L6pTMQKbqtOAMggYk1JCM1hxkUxksSWcKXY/81fAG1FF YmJiHiQNY4tpxP59qvCu+73vd50+mivVf5qStyTusJ1hEjcke4Ng2IWjQCmgb9MMs6 PxFv2dcWTTPAkiE4JTBUuZ3TzkK/oXdr7qFDt1tafjLCSK2TKmwnRUn4jb5OGc4GWL zv0K01d9xS7rw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] ext4: track truncated block range in ext4_truncate() for fast commit Reply-To: sashiko-reviews@lists.linux.dev To: "Xing Ma" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261130163929.14058-3-maxing.lan@bytedance.com> References: <20261130163929.14058-1-maxing.lan@bytedance.com> <20261130163929.14058-3-maxing.lan@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 17:09:54 +0000 X-Mailing-List: linux-ext4@vger.kernel.org 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: - [High] ext4: NULL pointer dereference in ext4_truncate() on failed journal restart - [Medium] ext4: ext4_truncate() skips ext4_fc_track_range() for indirect inodes -- commit 80834a510a624cb3f489ed5a5d96c25207ac7e1e Author: Xing Ma ext4: track truncated block range in ext4_truncate() for fast commit This commit calls ext4_fc_track_range() in ext4_truncate() after releasing i_data_sem so fast commit records the truncated logical block range when ext4_truncate_down() was bypassed or ran in an earlier transaction. > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 07a62d8569d31..9edb29ca2e1b7 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -5605,6 +5605,14 @@ int ext4_truncate(struct inode *inode) > ext4_ind_truncate(handle, inode); > =20 > up_write(&ei->i_data_sem); > + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { [Severity: Medium] Should ext4_fc_track_range() be called unconditionally here, as in ext4_truncate_down()? ext4_fc_track_inode() is called unconditionally earlier in ext4_truncate(), which resets ei->i_fc_lblk_len to 0 in a new transaction, and ext4_ind_truncate() removes the truncated tail from the extent status tree and can also restart the journal handle. When an indirect-mapped inode is truncated without calling ext4_fc_track_range(), ei->i_fc_lblk_len stays 0, so ext4_fc_snapshot_inode_data() returns 0 with no ranges instead of hitting an extent status tree miss (-EAGAIN) and falling back to a full commit. Fast commit then writes an EXT4_FC_TAG_INODE record for the indirect-mapped inode, causing ext4_fc_replay_inode() -> ext4_ext_clear_bb() to fail journal recovery with -EFSCORRUPTED. > + ext4_lblk_t start_lblk; > + > + start_lblk =3D inode->i_size > 0 ? > + (inode->i_size - 1) >> inode->i_blkbits : 0; > + ext4_fc_track_range(handle, inode, start_lblk, > + EXT_MAX_BLOCKS - 1); > + } > if (err) > goto out_stop; [Severity: High] Can calling ext4_fc_track_range() before checking err cause a NULL pointer dereference on handle->h_transaction? If ext4_ext_truncate() -> ext4_ext_remove_space() runs out of handle credits and calls jbd2__journal_restart() after the journal has aborted, stop_this_handle() sets handle->h_transaction =3D NULL before start_this_handle() fails with -EROFS. Calling ext4_fc_track_range() on that error path reaches ext4_fc_track_template(), which dereferences handle->h_transaction->t_tid before the if (err) check jumps to out_stop. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130163929.1405= 8-1-maxing.lan@bytedance.com?part=3D2