Linux filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, David Sterba <dsterba@suse.com>,
	Luis de Bethencourt <luisbg@kernel.org>,
	Salah Triki <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>,
	Dave Kleikamp <shaggy@kernel.org>,
	Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	Bob Copeland <me@bobcopeland.com>, Anders Larsen <al@alarsen.net>,
	linux-fsdevel@vger.kernel.org,
	jfs-discussion@lists.sourceforge.net, ntfs3@lists.linux.dev,
	linux-karma-devel@lists.sourceforge.net
Subject: [PATCH 06/10] affs: handle set_blocksize failures
Date: Mon, 11 May 2026 09:16:51 +0200	[thread overview]
Message-ID: <20260511071701.2456211-7-hch@lst.de> (raw)
In-Reply-To: <20260511071701.2456211-1-hch@lst.de>

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>
---
 fs/affs/affs.h  | 5 -----
 fs/affs/super.c | 6 ++++--
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index a0caf6ace860..44a3f69d275f 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -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)
 {
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 079f36e1ddec..b232251aa7bb 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -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
-- 
2.53.0


  parent reply	other threads:[~2026-05-11  7:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  7:16 fix crashes when mounting legacy file system with sector size > PAGE_SIZE Christoph Hellwig
2026-05-11  7:16 ` [PATCH 01/10] bfs: handle set_blocksize failures Christoph Hellwig
2026-05-11 16:10   ` Jan Kara
2026-05-11  7:16 ` [PATCH 02/10] hpfs: " Christoph Hellwig
2026-05-11  7:16 ` [PATCH 03/10] qnx4: " Christoph Hellwig
2026-05-11  7:42   ` Anders Larsen
2026-05-11  7:45     ` Christoph Hellwig
2026-05-11  8:20       ` Anders Larsen
2026-05-11  7:16 ` [PATCH 04/10] jfs: " Christoph Hellwig
2026-05-11  7:16 ` [PATCH 05/10] befs: " Christoph Hellwig
2026-05-11  7:16 ` Christoph Hellwig [this message]
2026-05-11  7:16 ` [PATCH 07/10] isofs: " Christoph Hellwig
2026-05-11 16:10   ` Jan Kara
2026-05-11  7:16 ` [PATCH 08/10] minix: " Christoph Hellwig
2026-05-11 16:08   ` Jan Kara
2026-05-12  6:08     ` Christoph Hellwig
2026-05-12 12:13       ` Christian Brauner
2026-05-11  7:16 ` [PATCH 09/10] ntfs3: " Christoph Hellwig
2026-05-11  7:16 ` [PATCH 10/10] omfs: " Christoph Hellwig
2026-05-11 13:40   ` Christian Brauner
2026-05-11 13:41 ` fix crashes when mounting legacy file system with sector size > PAGE_SIZE Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260511071701.2456211-7-hch@lst.de \
    --to=hch@lst.de \
    --cc=aivazian.tigran@gmail.com \
    --cc=al@alarsen.net \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=brauner@kernel.org \
    --cc=dsterba@suse.com \
    --cc=jack@suse.cz \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-karma-devel@lists.sourceforge.net \
    --cc=luisbg@kernel.org \
    --cc=me@bobcopeland.com \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=ntfs3@lists.linux.dev \
    --cc=salah.triki@gmail.com \
    --cc=shaggy@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox