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=1795928052; b=LmB4EJ41iqvY8XvMRPcGTv2YH9HDvUEQeQ129OgaDcLMCVy7jmHzuN3xULJDxXDR9s5E 8gpgCl2zigaaLjiU6kqQUMnMKkAMwAl+fUg4YnWBWEZX4sZnW3sHvy6ewd9GOcca0KNqw 4l9TAAA2wMSQPpctR/mFJwbSKpZHKIzAJB7LT0wM045LMCLmco/LW0R2rWCNDOxLAl71I 59WEXIVyndY0dhBGvtiigWxwou6gS+SgAwL3FofQE5vp4Ng7+eYkFj53KxHMd7hOT4l6X aPAtTgOj7SQOzvy4SPZ43pBpvDjFOm+ITAlB/0dLrXvCqVab9az2JdwGTd2ElJJ5RpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795928052; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=nzkdes2es+v0AKs9PmdlxyiCXGeXzRLrOCntp+/lgZQ=; b=vAPw2kNBrvSvRI8+x3IYLbkVnbqBBCO5mIkZO4bLZtfHaVYDqdfbYzYF7T6KqQhX3ANm s2VPBoTcKE2gVF8PEzF0EspM5to+IO59YAeDOJKFCTUgjpgouCVbCr4CoyBfXDjaWgehE +gixwpnTHUfgAlqGulS8Grsa5mITOJjpxFchSMOBIHM5h7m6nYKLvwNgVP+PMSR1OiUCn Aks1iF5OZWl9+dGorw3yfw0/GDXILovR5p4rHZfgNrge84l2AlKqXAx6mwRtskbl1aIfn UaF+SXP3ZX3jAEFxxEpQ6Lvn1RkCPfsgZ9jR3flUpbpxbV8wKoN75UIsmtJkIiMX6Qg== 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=Eyy5JnZf; 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 9AD1A606A31C for ; Sun, 29 Nov 2026 04:54:12 +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=Eyy5JnZf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A18B1F00896; Sun, 29 Nov 2026 04:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795928052; bh=nzkdes2es+v0AKs9PmdlxyiCXGeXzRLrOCntp+/lgZQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Eyy5JnZfVeZMN8vKfn1uf+Ye4LCBNLJZIQk7zc/AwzS+2mxwW2Hsk0ROb/tZSKfFo gNGZVXS9+scoRswYtYqBbcSWE0iuqxnNXhmeZ7NIw6NGgOYTObCuOnaZ48yjY+sbIz 6EviaG99BYuWUEE36nE5/ZxPOomI72Wdnv+4/n5nS4Yp23cQmq9G+wedqCIbX38Aqh NJt0sXehLUWKHaMVyUPsbcSGulh0N0Tjj7hoAr6SL/hb5xrZjDQtXAUei6eEw3aX++ YQDdJPQer/zz3l8KZXegp6rNxHNnZbNc7730SxPeRQ0Xc5VujVaUz23QT+exbYu1GL gs74AIMpcY0uQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ext4: do not report interrupted truncate as filesystem error Reply-To: sashiko-reviews@lists.linux.dev To: "Christopher Lusk" Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: <20261128-b4-ext4-eintr-v1-1-dc38ab39d1e7@northecho.dev> References: <20261128-b4-ext4-eintr-v1-1-dc38ab39d1e7@northecho.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 04:54:11 +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: incomplete truncate-down and orphan corruption in __ext4_std_error() - [High] ext4: infinite loop in ext4_orphan_cleanup() on -EINTR in __ext4_std_error() -- commit 58e5e8252974ec4aca8d6342e1b1e890589567bb Author: Christopher Lusk ext4: do not report interrupted truncate as filesystem error This commit ignores -EINTR in __ext4_std_error() when a fatal signal is pending on current. > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 880f664d6c04b..112dfae7a7386 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c [ ... ] > @@ -1022,6 +1023,9 @@ void __ext4_std_error(struct super_block *sb, const= char *function, > if (errno =3D=3D -EROFS && journal_current_handle() =3D=3D NULL && sb_r= donly(sb)) > return; > =20 > + if (errno =3D=3D -EINTR && fatal_signal_pending(current)) > + return; [Severity: High] Can ignoring -EINTR here leave a file half-truncated and leak its on-disk orphan entry when a shrinking truncate is interrupted? Unlike ext4_truncate_up(), ext4_truncate_down() first commits a transaction that adds the inode to the on-disk orphan list and shrinks i_size and i_disksize, and only then calls ext4_truncate(). On buffered_iomap, when the new size is not block-aligned, ext4_truncate() calls ext4_block_zero_eof() -> ... -> iomap_write_begin(), which returns -EINTR if a fatal signal is pending, aborting before freeing blocks past EOF or removing the on-disk orphan entry: fs/ext4/inode.c:ext4_truncate_down() { ... if (ext4_handle_valid(handle)) { ret =3D ext4_orphan_add(handle, inode); *orphan =3D 1; ... i_size_write(inode, newsize); __ext4_set_i_disksize(inode, newsize); up_write(&EXT4_I(inode)->i_data_sem); ret =3D ext4_mark_inode_dirty(handle, inode); ext4_journal_stop(handle); ... truncate_pagecache(inode, newsize); return ext4_truncate(inode); } ext4_setattr() then runs ext4_orphan_del(NULL, inode), which clears only the in-memory orphan state and relies on ext4_std_error() to mark the filesystem in error. Returning early from __ext4_std_error() leaves the filesystem read-write with blocks still allocated past i_disksize, an unzeroed tail block, and a leaked on-disk orphan slot (causing a later read-only remount or freeze to fail with EFSCORRUPTED in ext4_mark_recovery_complete()). [Severity: High] Could returning early here also cause an infinite loop in ext4_orphan_cleanup() if the mount or remount task has a fatal signal pending? When recovering a linked orphan (inode->i_nlink > 0) with a non-block-aligned i_size on the superblock orphan list, ext4_process_orphan() calls ext4_truncate(), which fails with -EINTR in ext4_block_zero_eof() before updating es->s_last_orphan: fs/ext4/orphan.c:ext4_process_orphan() { ... ret =3D ext4_truncate(inode); if (ret) { ext4_orphan_del(NULL, inode); ext4_std_error(inode->i_sb, ret); } ... } ext4_orphan_del(NULL, inode) only unlinks the in-memory list entry, and the while (es->s_last_orphan) loop in ext4_orphan_cleanup() relies on EXT4_ERROR_FS being set by ext4_std_error() to break out. Without EXT4_ERROR_FS, es->s_last_orphan never advances and the loop spins forever on the same inode. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128-b4-ext4-ei= ntr-v1-1-dc38ab39d1e7@northecho.dev?part=3D1