sync jfs remount and jfs ioctrl with s_umount
#syz test: upstream master
diff --git a/fs/jfs/jfs_discard.c b/fs/jfs/jfs_discard.c
index 575cb2ba74fc..5f4b305030ad 100644
--- a/fs/jfs/jfs_discard.c
+++ b/fs/jfs/jfs_discard.c
@@ -65,7 +65,7 @@ void jfs_issue_discard(struct inode *ip, u64 blkno, u64 nblocks)
int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
{
struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;
- struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
+ struct bmap *bmp;
struct super_block *sb = ipbmap->i_sb;
int agno, agno_end;
u64 start, end, minlen;
@@ -83,10 +83,15 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
if (minlen == 0)
minlen = 1;
+ down_read(&sb->s_umount);
+ bmp = JFS_SBI(ip->i_sb)->bmap;
+
if (minlen > bmp->db_agsize ||
start >= bmp->db_mapsize ||
- range->len < sb->s_blocksize)
+ range->len < sb->s_blocksize) {
+ up_read(&sb->s_umount);
return -EINVAL;
+ }
if (end >= bmp->db_mapsize)
end = bmp->db_mapsize - 1;
@@ -100,6 +105,8 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
trimmed += dbDiscardAG(ip, agno, minlen);
agno++;
}
+
+ up_read(&sb->s_umount);
range->len = trimmed << sb->s_blocksize_bits;
return 0;
Hello, syzbot has tested the proposed patch and the reproducer did not trigger any issue: Reported-by: syzbot+3c010e21296f33a5dc16@syzkaller.appspotmail.com Tested-by: syzbot+3c010e21296f33a5dc16@syzkaller.appspotmail.com Tested on: commit: 60f0560f Merge tag 'nfs-for-6.11-2' of git://git.linux.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1159e82b980000 kernel config: https://syzkaller.appspot.com/x/.config?x=4fc2afd52fd008bb dashboard link: https://syzkaller.appspot.com/bug?extid=3c010e21296f33a5dc16 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=12dc9bd5980000 Note: testing is done by a robot and is best-effort only.
© 2016 - 2026 Red Hat, Inc.