[PATCH AUTOSEL 6.18-5.10] omfs: handle set_blocksize failures

From: Sasha Levin

Date: Mon Aug 31 2026 - 10:13:34 EST


From: Christoph Hellwig <hch@xxxxxx>

[ Upstream commit 18c3d6fcb557f920c9143711497625e70153874c ]

omfs 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@xxxxxx>

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Link: https://patch.msgid.link/20260511071701.2456211-11-hch@xxxxxx
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---

LLM Generated explanations, may be completely bogus:

The background git search finished. It found no commit matching
“set_blocksize failures” or “handle set_blocksize” in this tree, which
confirms the OMFS fix is not present in 6.18.44 yet. Recent Christoph
Hellwig changes under `fs/omfs/` are unrelated (`CONFIG_BUFFER_HEAD`,
`remove ->writepage`, etc.).

That doesn’t change the earlier conclusion: the unchecked
`sb_set_blocksize()` calls are still at `fs/omfs/inode.c:480` and
`:532`, and the fix should be backported.

**YES**

fs/omfs/inode.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 31218d89b7580..14369efc70d81 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -477,7 +477,8 @@ static int omfs_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_time_min = 0;
sb->s_time_max = U64_MAX / MSEC_PER_SEC;

- sb_set_blocksize(sb, 0x200);
+ if (!sb_set_blocksize(sb, 0x200))
+ goto end;

bh = sb_bread(sb, 0);
if (!bh)
@@ -529,7 +530,8 @@ static int omfs_fill_super(struct super_block *sb, struct fs_context *fc)
* Use sys_blocksize as the fs block since it is smaller than a
* page while the fs blocksize can be larger.
*/
- sb_set_blocksize(sb, sbi->s_sys_blocksize);
+ if (!sb_set_blocksize(sb, sbi->s_sys_blocksize))
+ goto out_brelse_bh;

/*
* ...and the difference goes into a shift. sys_blocksize is always
--
2.53.0