public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hfsplus: limit sb_maxbytes to partition size
@ 2026-03-03  8:28 Hyunchul Lee
  2026-03-04 13:08 ` Christoph Hellwig
  0 siblings, 1 reply; 17+ messages in thread
From: Hyunchul Lee @ 2026-03-03  8:28 UTC (permalink / raw)
  To: Viacheslav Dubeyko, John Paul Adrian Glaubitz, Yangtao Li
  Cc: linux-fsdevel, linux-kernel, cheol.lee

s_maxbytes currently is set to MAX_LFS_FILESIZE,
which allows writes beyond the partition size. As a result,
large-offset writes on small partitions can fail late
with ENOSPC.

Set s_maxbytes to the partition size.

With this change, the large-offset writes are rejected
early by `generic_write_check_limit()` with EFBIG.

This patch also fixes generic/268.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
---
 fs/hfsplus/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 7229a8ae89f9..18350abc659b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -500,7 +500,8 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
 
 	/* Set up operations so we can load metadata */
 	sb->s_op = &hfsplus_sops;
-	sb->s_maxbytes = MAX_LFS_FILESIZE;
+	sb->s_maxbytes = (loff_t)min(MAX_LFS_FILESIZE,
+				     (u64)sbi->total_blocks << sbi->alloc_blksz_shift);
 
 	if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
 		pr_warn("Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended.  mounting read-only.\n");
-- 
2.43.0


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

end of thread, other threads:[~2026-03-09 23:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03  8:28 [PATCH] hfsplus: limit sb_maxbytes to partition size Hyunchul Lee
2026-03-04 13:08 ` Christoph Hellwig
2026-03-04 20:04   ` Viacheslav Dubeyko
2026-03-05  0:29     ` Hyunchul Lee
2026-03-05  0:46       ` Viacheslav Dubeyko
2026-03-05  1:52         ` Hyunchul Lee
2026-03-05 23:21           ` Viacheslav Dubeyko
2026-03-06  0:57             ` Hyunchul Lee
2026-03-06  1:23               ` Viacheslav Dubeyko
2026-03-06  2:05                 ` Hyunchul Lee
2026-03-06 20:08                   ` Viacheslav Dubeyko
2026-03-09  0:52                     ` Hyunchul Lee
2026-03-09 19:47                       ` Viacheslav Dubeyko
2026-03-09 23:25                         ` Hyunchul Lee
2026-03-05 14:27       ` hch
2026-03-06  0:40         ` Hyunchul Lee
2026-03-04 23:49   ` Hyunchul Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox