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

From: Sasha Levin

Date: Mon Aug 31 2026 - 10:09:45 EST


From: Christoph Hellwig <hch@xxxxxx>

[ Upstream commit 7597d42a25332617a3dfe596758d780ec6c028d7 ]

befs 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>
Link: https://patch.msgid.link/20260511071701.2456211-6-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 searches finished and match the earlier analysis.

On **v6.18.44**, the `befs: handle set_blocksize failures` commit is not
present (no matches on HEAD). BEFS still ignores the return value at
`fs/befs/linuxvfs.c:861`, while a related fix (`173b066f5826e` — check
`sb_min_blocksize` return) is already in the tree. The patch applies
cleanly and belongs in the same crash-fix series as the romfs backport
already in this tree.

**Verdict: YES** — backport recommended.

fs/befs/linuxvfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 8f430ff8e4458..cd9921b977a72 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -858,7 +858,8 @@ befs_fill_super(struct super_block *sb, struct fs_context *fc)
*/
sb->s_magic = BEFS_SUPER_MAGIC;
/* Set real blocksize of fs */
- sb_set_blocksize(sb, (ulong) befs_sb->block_size);
+ if (!sb_set_blocksize(sb, (ulong) befs_sb->block_size))
+ goto unacquire_priv_sbp;
sb->s_op = &befs_sops;
sb->s_export_op = &befs_export_operations;
sb->s_time_min = 0;
--
2.53.0