]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
affs: handle set_blocksize failures
authorChristoph Hellwig <hch@lst.de>
Mon, 11 May 2026 07:16:51 +0000 (09:16 +0200)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 May 2026 11:39:35 +0000 (13:39 +0200)
affs uses buffer_heads, which don't handle block size > PAGE_SIZE well.
Without this, mounting we will hit the

        BUG_ON(offset >= folio_size(folio));

in folio_set_bh on the first __bread_gfp call.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260511071701.2456211-7-hch@lst.de
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/affs/affs.h
fs/affs/super.c

index a0caf6ace8601f72c8ae32623e996fa685ec849d..44a3f69d275f96359c7628b0b90de1a1b7a77947 100644 (file)
@@ -227,11 +227,6 @@ static inline bool affs_validblock(struct super_block *sb, int block)
               block < AFFS_SB(sb)->s_partition_size);
 }
 
-static inline void
-affs_set_blocksize(struct super_block *sb, int size)
-{
-       sb_set_blocksize(sb, size);
-}
 static inline struct buffer_head *
 affs_bread(struct super_block *sb, int block)
 {
index 079f36e1ddec13cbe3358d570a144635ccb6aaf3..b232251aa7bbd008aeb758b5c94fe8674691268a 100644 (file)
@@ -358,7 +358,8 @@ static int affs_fill_super(struct super_block *sb, struct fs_context *fc)
        size = bdev_nr_sectors(sb->s_bdev);
        pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size);
 
-       affs_set_blocksize(sb, PAGE_SIZE);
+       if (!sb_set_blocksize(sb, PAGE_SIZE))
+               return -EINVAL;
        /* Try to find root block. Its location depends on the block size. */
 
        i = bdev_logical_block_size(sb->s_bdev);
@@ -374,7 +375,8 @@ static int affs_fill_super(struct super_block *sb, struct fs_context *fc)
                if (ctx->root_block < 0)
                        sbi->s_root_block = (ctx->reserved + size - 1) / 2;
                pr_debug("setting blocksize to %d\n", blocksize);
-               affs_set_blocksize(sb, blocksize);
+               if (!sb_set_blocksize(sb, blocksize))
+                       return -EINVAL;
                sbi->s_partition_size = size;
 
                /* The root block location that was calculated above is not