All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix maximum orphan file size check
@ 2026-10-02 11:50 Jan Kara
  2026-10-02 11:57 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jan Kara @ 2026-10-02 11:50 UTC (permalink / raw)
  To: Ted Tso
  Cc: linux-ext4, Mikulas Patocka, Baokun Li, Zhang Yi, Ojaswin Mujoo,
	Ritesh Harjani, Jan Kara, stable

Mikulas reported that e2fsprogs 1.47.4 with 1k fs blocksize by default
creates orphan file of the size the kernel rejects. This is because that
version of e2fsprogs creates 2MB file by default regardless of the block
size and with 1k blocks that's more than the limit of 512 fs blocks.
Fix the check to make kernel accept any file upto those 2MB regardless
of the number of blocks.

Fixes: 7c11c56eb32e ("ext4: align max orphan file size with e2fsprogs limit")
CC: stable@vger.kernel.org
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Link: https://lore.kernel.org/all/e65cdbfe-3ff9-4638-fbd3-4d8f8880966f@redhat.com
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/orphan.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index b4675aa7ea96..7394d04e0fd9 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -576,6 +576,7 @@ int ext4_init_orphan_info(struct super_block *sb)
 	int inodes_per_ob = ext4_inodes_per_orphan_block(sb);
 	struct ext4_orphan_block_tail *ot;
 	ino_t orphan_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_orphan_file_inum);
+	loff_t max_size;
 
 	if (!ext4_has_feature_orphan_file(sb))
 		return 0;
@@ -589,8 +590,13 @@ int ext4_init_orphan_info(struct super_block *sb)
 	 * This is just an artificial limit to prevent corrupted fs from
 	 * consuming absurd amounts of memory when pinning blocks of orphan
 	 * file in memory.
+	 *
+	 * e2fsprogs 1.47.4 produces 2MB orphan files by default regardless
+	 * of the number of blocks so that's where the second limit comes from.
 	 */
-	if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {
+	max_size = max(EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits,
+		       2 << 20);
+	if (inode->i_size > max_size) {
 		ext4_msg(sb, KERN_ERR, "orphan file too big: %llu",
 			 (unsigned long long)inode->i_size);
 		ret = -EFSCORRUPTED;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-08  3:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 11:50 [PATCH] ext4: Fix maximum orphan file size check Jan Kara
2026-10-02 11:57 ` sashiko-bot
2026-10-02 12:15 ` Mikulas Patocka
2026-10-03 15:32 ` Baokun Li
2026-10-08  2:47 ` Zhang Yi

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.