* [PATCH v4 2/5] exfat: check return value of sb_min_blocksize in exfat_read_boot_sector
2025-11-03 16:36 [PATCH v4 1/5] vfat: fix missing sb_min_blocksize() return value checks Yongpeng Yang
@ 2025-11-03 16:36 ` Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 3/5] isofs: check the return value of sb_min_blocksize() in isofs_fill_super Yongpeng Yang
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang @ 2025-11-03 16:36 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, linux-block, stable, Matthew Wilcox,
Darrick J . Wong, Yongpeng Yang
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
sb_min_blocksize() may return 0. Check its return value to avoid
accessing the filesystem super block when sb->s_blocksize is 0.
Cc: <stable@vger.kernel.org> # v6.15
Fixes: 719c1e1829166d ("exfat: add super block operations")
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/exfat/super.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 7f9592856bf7..74d451f732c7 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -433,7 +433,10 @@ static int exfat_read_boot_sector(struct super_block *sb)
struct exfat_sb_info *sbi = EXFAT_SB(sb);
/* set block size to read super block */
- sb_min_blocksize(sb, 512);
+ if (!sb_min_blocksize(sb, 512)) {
+ exfat_err(sb, "unable to set blocksize");
+ return -EINVAL;
+ }
/* read boot sector */
sbi->boot_bh = sb_bread(sb, 0);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 3/5] isofs: check the return value of sb_min_blocksize() in isofs_fill_super
2025-11-03 16:36 [PATCH v4 1/5] vfat: fix missing sb_min_blocksize() return value checks Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 2/5] exfat: check return value of sb_min_blocksize in exfat_read_boot_sector Yongpeng Yang
@ 2025-11-03 16:36 ` Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Yongpeng Yang
3 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang @ 2025-11-03 16:36 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, linux-block, stable, Matthew Wilcox,
Darrick J . Wong, Yongpeng Yang
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
sb_min_blocksize() may return 0. Check its return value to avoid
opt->blocksize and sb->s_blocksize is 0.
Cc: <stable@vger.kernel.org> # v6.15
Fixes: 1b17a46c9243e9 ("isofs: convert isofs to use the new mount API")
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/isofs/inode.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 6f0e6b19383c..ad3143d4066b 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -610,6 +610,11 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc)
goto out_freesbi;
}
opt->blocksize = sb_min_blocksize(s, opt->blocksize);
+ if (!opt->blocksize) {
+ printk(KERN_ERR
+ "ISOFS: unable to set blocksize\n");
+ goto out_freesbi;
+ }
sbi->s_high_sierra = 0; /* default is iso9660 */
sbi->s_session = opt->session;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super
2025-11-03 16:36 [PATCH v4 1/5] vfat: fix missing sb_min_blocksize() return value checks Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 2/5] exfat: check return value of sb_min_blocksize in exfat_read_boot_sector Yongpeng Yang
2025-11-03 16:36 ` [PATCH v4 3/5] isofs: check the return value of sb_min_blocksize() in isofs_fill_super Yongpeng Yang
@ 2025-11-03 16:36 ` Yongpeng Yang
2025-11-04 15:42 ` Darrick J. Wong
2025-11-03 16:36 ` [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Yongpeng Yang
3 siblings, 1 reply; 10+ messages in thread
From: Yongpeng Yang @ 2025-11-03 16:36 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, linux-block, stable, Matthew Wilcox,
Darrick J . Wong, Yongpeng Yang
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
sb_min_blocksize() may return 0. Check its return value to avoid the
filesystem super block when sb->s_blocksize is 0.
Cc: <stable@vger.kernel.org> # v6.15
Fixes: a64e5a596067bd ("bdev: add back PAGE_SIZE block size validation
for sb_set_blocksize()")
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
fs/xfs/xfs_super.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 1067ebb3b001..bc71aa9dcee8 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1693,7 +1693,10 @@ xfs_fs_fill_super(
if (error)
return error;
- sb_min_blocksize(sb, BBSIZE);
+ if (!sb_min_blocksize(sb, BBSIZE)) {
+ xfs_err(mp, "unable to set blocksize");
+ return -EINVAL;
+ }
sb->s_xattr = xfs_xattr_handlers;
sb->s_export_op = &xfs_export_operations;
#ifdef CONFIG_XFS_QUOTA
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super
2025-11-03 16:36 ` [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super Yongpeng Yang
@ 2025-11-04 15:42 ` Darrick J. Wong
2025-11-05 2:08 ` Yongpeng Yang
0 siblings, 1 reply; 10+ messages in thread
From: Darrick J. Wong @ 2025-11-04 15:42 UTC (permalink / raw)
To: Yongpeng Yang
Cc: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig, linux-xfs,
linux-fsdevel, linux-block, stable, Matthew Wilcox, Yongpeng Yang
On Tue, Nov 04, 2025 at 12:36:17AM +0800, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> sb_min_blocksize() may return 0. Check its return value to avoid the
> filesystem super block when sb->s_blocksize is 0.
>
> Cc: <stable@vger.kernel.org> # v6.15
> Fixes: a64e5a596067bd ("bdev: add back PAGE_SIZE block size validation
> for sb_set_blocksize()")
Odd line wrapping, does this actually work with $stablemaintainer
scripts?
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
Otherwise looks fine to me
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 1067ebb3b001..bc71aa9dcee8 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1693,7 +1693,10 @@ xfs_fs_fill_super(
> if (error)
> return error;
>
> - sb_min_blocksize(sb, BBSIZE);
> + if (!sb_min_blocksize(sb, BBSIZE)) {
> + xfs_err(mp, "unable to set blocksize");
> + return -EINVAL;
> + }
> sb->s_xattr = xfs_xattr_handlers;
> sb->s_export_op = &xfs_export_operations;
> #ifdef CONFIG_XFS_QUOTA
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super
2025-11-04 15:42 ` Darrick J. Wong
@ 2025-11-05 2:08 ` Yongpeng Yang
0 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang @ 2025-11-05 2:08 UTC (permalink / raw)
To: Darrick J. Wong, Yongpeng Yang
Cc: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig, linux-xfs,
linux-fsdevel, linux-block, stable, Matthew Wilcox, Yongpeng Yang
On 11/4/25 23:42, Darrick J. Wong wrote:
> On Tue, Nov 04, 2025 at 12:36:17AM +0800, Yongpeng Yang wrote:
>> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>>
>> sb_min_blocksize() may return 0. Check its return value to avoid the
>> filesystem super block when sb->s_blocksize is 0.
>>
>> Cc: <stable@vger.kernel.org> # v6.15
>> Fixes: a64e5a596067bd ("bdev: add back PAGE_SIZE block size validation
>> for sb_set_blocksize()")
>
> Odd line wrapping, does this actually work with $stablemaintainer
> scripts?
>
Sorry for my mistake. I’ve sent v6 patch to fix this issue.
Yongpeng,
>> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> Otherwise looks fine to me
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>
> --D
>
>> ---
>> fs/xfs/xfs_super.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>> index 1067ebb3b001..bc71aa9dcee8 100644
>> --- a/fs/xfs/xfs_super.c
>> +++ b/fs/xfs/xfs_super.c
>> @@ -1693,7 +1693,10 @@ xfs_fs_fill_super(
>> if (error)
>> return error;
>>
>> - sb_min_blocksize(sb, BBSIZE);
>> + if (!sb_min_blocksize(sb, BBSIZE)) {
>> + xfs_err(mp, "unable to set blocksize");
>> + return -EINVAL;
>> + }
>> sb->s_xattr = xfs_xattr_handlers;
>> sb->s_export_op = &xfs_export_operations;
>> #ifdef CONFIG_XFS_QUOTA
>> --
>> 2.43.0
>>
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize()
2025-11-03 16:36 [PATCH v4 1/5] vfat: fix missing sb_min_blocksize() return value checks Yongpeng Yang
` (2 preceding siblings ...)
2025-11-03 16:36 ` [PATCH v4 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super Yongpeng Yang
@ 2025-11-03 16:36 ` Yongpeng Yang
2025-11-03 16:40 ` kernel test robot
` (2 more replies)
3 siblings, 3 replies; 10+ messages in thread
From: Yongpeng Yang @ 2025-11-03 16:36 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, linux-block, stable, Matthew Wilcox,
Darrick J . Wong, Yongpeng Yang
From: Yongpeng Yang <yangyongpeng@xiaomi.com>
When sb_min_blocksize() returns 0 and the return value is not checked,
it may lead to a situation where sb->s_blocksize is 0 when
accessing the filesystem super block. After commit a64e5a596067bd
("bdev: add back PAGE_SIZE block size validation for
sb_set_blocksize()"), this becomes more likely to happen when the
block device’s logical_block_size is larger than PAGE_SIZE and the
filesystem is unformatted. Add the __must_check attribute to ensure
callers always check the return value.
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
block/bdev.c | 2 +-
include/linux/fs.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/bdev.c b/block/bdev.c
index 810707cca970..638f0cd458ae 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
EXPORT_SYMBOL(sb_set_blocksize);
-int sb_min_blocksize(struct super_block *sb, int size)
+int __must_check sb_min_blocksize(struct super_block *sb, int size)
{
int minsize = bdev_logical_block_size(sb->s_bdev);
if (size < minsize)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c895146c1444..26d4ca0f859a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3424,7 +3424,7 @@ extern void inode_sb_list_add(struct inode *inode);
extern void inode_add_lru(struct inode *inode);
extern int sb_set_blocksize(struct super_block *, int);
-extern int sb_min_blocksize(struct super_block *, int);
+extern int __must_check sb_min_blocksize(struct super_block *, int);
int generic_file_mmap(struct file *, struct vm_area_struct *);
int generic_file_mmap_prepare(struct vm_area_desc *desc);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize()
2025-11-03 16:36 ` [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Yongpeng Yang
@ 2025-11-03 16:40 ` kernel test robot
2025-11-04 8:59 ` Jan Kara
2025-11-04 15:57 ` Darrick J. Wong
2 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-11-03 16:40 UTC (permalink / raw)
To: Yongpeng Yang; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize()
Link: https://lore.kernel.org/stable/20251103163617.151045-6-yangyongpeng.storage%40gmail.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize()
2025-11-03 16:36 ` [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Yongpeng Yang
2025-11-03 16:40 ` kernel test robot
@ 2025-11-04 8:59 ` Jan Kara
2025-11-04 15:57 ` Darrick J. Wong
2 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2025-11-04 8:59 UTC (permalink / raw)
To: Yongpeng Yang
Cc: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig, linux-xfs,
linux-fsdevel, linux-block, stable, Matthew Wilcox,
Darrick J . Wong, Yongpeng Yang
On Tue 04-11-25 00:36:18, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> When sb_min_blocksize() returns 0 and the return value is not checked,
> it may lead to a situation where sb->s_blocksize is 0 when
> accessing the filesystem super block. After commit a64e5a596067bd
> ("bdev: add back PAGE_SIZE block size validation for
> sb_set_blocksize()"), this becomes more likely to happen when the
> block device’s logical_block_size is larger than PAGE_SIZE and the
> filesystem is unformatted. Add the __must_check attribute to ensure
> callers always check the return value.
>
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> block/bdev.c | 2 +-
> include/linux/fs.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/bdev.c b/block/bdev.c
> index 810707cca970..638f0cd458ae 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
>
> EXPORT_SYMBOL(sb_set_blocksize);
>
> -int sb_min_blocksize(struct super_block *sb, int size)
> +int __must_check sb_min_blocksize(struct super_block *sb, int size)
> {
> int minsize = bdev_logical_block_size(sb->s_bdev);
> if (size < minsize)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c895146c1444..26d4ca0f859a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3424,7 +3424,7 @@ extern void inode_sb_list_add(struct inode *inode);
> extern void inode_add_lru(struct inode *inode);
>
> extern int sb_set_blocksize(struct super_block *, int);
> -extern int sb_min_blocksize(struct super_block *, int);
> +extern int __must_check sb_min_blocksize(struct super_block *, int);
>
> int generic_file_mmap(struct file *, struct vm_area_struct *);
> int generic_file_mmap_prepare(struct vm_area_desc *desc);
> --
> 2.43.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize()
2025-11-03 16:36 ` [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Yongpeng Yang
2025-11-03 16:40 ` kernel test robot
2025-11-04 8:59 ` Jan Kara
@ 2025-11-04 15:57 ` Darrick J. Wong
2 siblings, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2025-11-04 15:57 UTC (permalink / raw)
To: Yongpeng Yang
Cc: Namjae Jeon, Sungjong Seo, OGAWA Hirofumi, Jan Kara,
Carlos Maiolino, Jens Axboe, Greg Kroah-Hartman, Sasha Levin,
Alexander Viro, Christian Brauner, Christoph Hellwig, linux-xfs,
linux-fsdevel, linux-block, stable, Matthew Wilcox, Yongpeng Yang
On Tue, Nov 04, 2025 at 12:36:18AM +0800, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> When sb_min_blocksize() returns 0 and the return value is not checked,
> it may lead to a situation where sb->s_blocksize is 0 when
> accessing the filesystem super block. After commit a64e5a596067bd
> ("bdev: add back PAGE_SIZE block size validation for
> sb_set_blocksize()"), this becomes more likely to happen when the
> block device’s logical_block_size is larger than PAGE_SIZE and the
> filesystem is unformatted. Add the __must_check attribute to ensure
> callers always check the return value.
>
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
Looks good to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> block/bdev.c | 2 +-
> include/linux/fs.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/bdev.c b/block/bdev.c
> index 810707cca970..638f0cd458ae 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
>
> EXPORT_SYMBOL(sb_set_blocksize);
>
> -int sb_min_blocksize(struct super_block *sb, int size)
> +int __must_check sb_min_blocksize(struct super_block *sb, int size)
> {
> int minsize = bdev_logical_block_size(sb->s_bdev);
> if (size < minsize)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c895146c1444..26d4ca0f859a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3424,7 +3424,7 @@ extern void inode_sb_list_add(struct inode *inode);
> extern void inode_add_lru(struct inode *inode);
>
> extern int sb_set_blocksize(struct super_block *, int);
> -extern int sb_min_blocksize(struct super_block *, int);
> +extern int __must_check sb_min_blocksize(struct super_block *, int);
>
> int generic_file_mmap(struct file *, struct vm_area_struct *);
> int generic_file_mmap_prepare(struct vm_area_desc *desc);
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread