mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Merge patch series "fix crashes when mounting legacy file system with sector size > PAGE_SIZE"
Christoph Hellwig <hch@lst.de> says: Due to an almost comical failure on my part, my work in progress test case failed to create any file system on a 64k block size loop device, and then tried to mount it, leading to a probe of file system built into my kernel. Roughly the first half of the series are file systems that actually crashed, but I fixed up all the pattern of missing error handling that I saw. * patches from https://patch.msgid.link/20260511071701.2456211-1-hch@lst.de: omfs: handle set_blocksize failures ntfs3: handle set_blocksize failures minix: handle set_blocksize failures isofs: handle set_blocksize failures affs: handle set_blocksize failures befs: handle set_blocksize failures jfs: handle set_blocksize failures qnx4: handle set_blocksize failures hpfs: handle set_blocksize failures bfs: handle set_blocksize failures Link: https://patch.msgid.link/20260511071701.2456211-1-hch@lst.de Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
commit
d90e60ced4
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -860,7 +860,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;
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ static int bfs_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
s->s_time_min = 0;
|
||||
s->s_time_max = U32_MAX;
|
||||
|
||||
sb_set_blocksize(s, BFS_BSIZE);
|
||||
if (!sb_set_blocksize(s, BFS_BSIZE))
|
||||
goto out;
|
||||
|
||||
sbh = sb_bread(s, 0);
|
||||
if (!sbh)
|
||||
|
|
|
|||
|
|
@ -523,7 +523,8 @@ static int hpfs_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
hpfs_lock(s);
|
||||
|
||||
/*sbi->sb_mounting = 1;*/
|
||||
sb_set_blocksize(s, 512);
|
||||
if (!sb_set_blocksize(s, 512))
|
||||
goto bail0;
|
||||
sbi->sb_fs_size = -1;
|
||||
if (!(bootblock = hpfs_map_sector(s, 0, &bh0, 0))) goto bail1;
|
||||
if (!(superblock = hpfs_map_sector(s, 16, &bh1, 1))) goto bail2;
|
||||
|
|
|
|||
|
|
@ -818,7 +818,8 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
* entries. By forcing the blocksize in this way, we ensure
|
||||
* that we will never be required to do this.
|
||||
*/
|
||||
sb_set_blocksize(s, orig_zonesize);
|
||||
if (!sb_set_blocksize(s, orig_zonesize))
|
||||
goto out_freesbi;
|
||||
|
||||
sbi->s_nls_iocharset = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -491,7 +491,8 @@ static int jfs_fill_super(struct super_block *sb, struct fs_context *fc)
|
|||
/*
|
||||
* Initialize blocksize to 4K.
|
||||
*/
|
||||
sb_set_blocksize(sb, PSIZE);
|
||||
if (!sb_set_blocksize(sb, PSIZE))
|
||||
goto out_unload;
|
||||
|
||||
/*
|
||||
* Set method vectors.
|
||||
|
|
|
|||
|
|
@ -292,7 +292,8 @@ static int minix_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
sbi->s_namelen = 60;
|
||||
sbi->s_version = MINIX_V3;
|
||||
sbi->s_mount_state = MINIX_VALID_FS;
|
||||
sb_set_blocksize(s, m3s->s_blocksize);
|
||||
if (!sb_set_blocksize(s, m3s->s_blocksize))
|
||||
goto out;
|
||||
s->s_max_links = MINIX2_LINK_MAX;
|
||||
} else
|
||||
goto out_no_fs;
|
||||
|
|
|
|||
|
|
@ -1174,7 +1174,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|||
rec->total = cpu_to_le32(sbi->record_size);
|
||||
((struct ATTRIB *)Add2Ptr(rec, ao))->type = ATTR_END;
|
||||
|
||||
sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE));
|
||||
if (!sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE))) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
sbi->block_mask = sb->s_blocksize - 1;
|
||||
sbi->blocks_per_cluster = sbi->cluster_size >> sb->s_blocksize_bits;
|
||||
|
|
@ -1225,7 +1228,8 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|||
/*
|
||||
* Try alternative boot (last sector)
|
||||
*/
|
||||
sb_set_blocksize(sb, block_size);
|
||||
if (!sb_set_blocksize(sb, block_size))
|
||||
return -EINVAL;
|
||||
hint = "Alternative boot";
|
||||
dev_size = dev_size0; /* restore original size. */
|
||||
goto read_boot;
|
||||
|
|
|
|||
|
|
@ -478,7 +478,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)
|
||||
|
|
@ -530,7 +531,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
|
||||
|
|
|
|||
|
|
@ -202,7 +202,8 @@ static int qnx4_fill_super(struct super_block *s, struct fs_context *fc)
|
|||
return -ENOMEM;
|
||||
s->s_fs_info = qs;
|
||||
|
||||
sb_set_blocksize(s, QNX4_BLOCK_SIZE);
|
||||
if (!sb_set_blocksize(s, QNX4_BLOCK_SIZE))
|
||||
return -EINVAL;
|
||||
|
||||
s->s_op = &qnx4_sops;
|
||||
s->s_magic = QNX4_SUPER_MAGIC;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user