Skip to content

Commit 75fdd57

Browse files
committed
Merge patch series "sb_min_blocksize() fixes"
Enforce checking of sb_min_blocksize() calls and update all callers accordingly. * patches from https://patch.msgid.link/20251104125009.2111925-2-yangyongpeng.storage@gmail.com: block: add __must_check attribute to sb_min_blocksize() xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super isofs: check the return value of sb_min_blocksize() in isofs_fill_super exfat: check return value of sb_min_blocksize in exfat_read_boot_sector vfat: fix missing sb_min_blocksize() return value checks Link: https://patch.msgid.link/20251104125009.2111925-2-yangyongpeng.storage@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 90f601b + 8637fa8 commit 75fdd57

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

block/bdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
231231

232232
EXPORT_SYMBOL(sb_set_blocksize);
233233

234-
int sb_min_blocksize(struct super_block *sb, int size)
234+
int __must_check sb_min_blocksize(struct super_block *sb, int size)
235235
{
236236
int minsize = bdev_logical_block_size(sb->s_bdev);
237237
if (size < minsize)

fs/exfat/super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ static int exfat_read_boot_sector(struct super_block *sb)
433433
struct exfat_sb_info *sbi = EXFAT_SB(sb);
434434

435435
/* set block size to read super block */
436-
sb_min_blocksize(sb, 512);
436+
if (!sb_min_blocksize(sb, 512)) {
437+
exfat_err(sb, "unable to set blocksize");
438+
return -EINVAL;
439+
}
437440

438441
/* read boot sector */
439442
sbi->boot_bh = sb_bread(sb, 0);

fs/fat/inode.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,8 +1595,12 @@ int fat_fill_super(struct super_block *sb, struct fs_context *fc,
15951595

15961596
setup(sb); /* flavour-specific stuff that needs options */
15971597

1598+
error = -EINVAL;
1599+
if (!sb_min_blocksize(sb, 512)) {
1600+
fat_msg(sb, KERN_ERR, "unable to set blocksize");
1601+
goto out_fail;
1602+
}
15981603
error = -EIO;
1599-
sb_min_blocksize(sb, 512);
16001604
bh = sb_bread(sb, 0);
16011605
if (bh == NULL) {
16021606
fat_msg(sb, KERN_ERR, "unable to read boot sector");

fs/isofs/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc)
610610
goto out_freesbi;
611611
}
612612
opt->blocksize = sb_min_blocksize(s, opt->blocksize);
613+
if (!opt->blocksize) {
614+
printk(KERN_ERR
615+
"ISOFS: unable to set blocksize\n");
616+
goto out_freesbi;
617+
}
613618

614619
sbi->s_high_sierra = 0; /* default is iso9660 */
615620
sbi->s_session = opt->session;

fs/xfs/xfs_super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,10 @@ xfs_fs_fill_super(
16621662
if (error)
16631663
return error;
16641664

1665-
sb_min_blocksize(sb, BBSIZE);
1665+
if (!sb_min_blocksize(sb, BBSIZE)) {
1666+
xfs_err(mp, "unable to set blocksize");
1667+
return -EINVAL;
1668+
}
16661669
sb->s_xattr = xfs_xattr_handlers;
16671670
sb->s_export_op = &xfs_export_operations;
16681671
#ifdef CONFIG_XFS_QUOTA

include/linux/fs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,8 +3423,8 @@ static inline void remove_inode_hash(struct inode *inode)
34233423
extern void inode_sb_list_add(struct inode *inode);
34243424
extern void inode_add_lru(struct inode *inode);
34253425

3426-
extern int sb_set_blocksize(struct super_block *, int);
3427-
extern int sb_min_blocksize(struct super_block *, int);
3426+
int sb_set_blocksize(struct super_block *sb, int size);
3427+
int __must_check sb_min_blocksize(struct super_block *sb, int size);
34283428

34293429
int generic_file_mmap(struct file *, struct vm_area_struct *);
34303430
int generic_file_mmap_prepare(struct vm_area_desc *desc);

0 commit comments

Comments
 (0)