* [syzbot] [gfs2?] UBSAN: shift-out-of-bounds in gfs2_fill_super
@ 2025-04-11 8:28 syzbot
2025-04-12 5:07 ` [PATCH] gfs2: capture blocksize set failed Edward Adam Davis
0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2025-04-11 8:28 UTC (permalink / raw)
To: agruenba, gfs2, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: a4cda136f021 Add linux-next specific files for 20250404
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=15dc523f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=8a257c454bb1afb7
dashboard link: https://syzkaller.appspot.com/bug?extid=b0018b7468b2af33b4d5
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/59048bc9c206/disk-a4cda136.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ad2ba7306f20/vmlinux-a4cda136.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b3bef7acbf10/bzImage-a4cda136.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b0018b7468b2af33b4d5@syzkaller.appspotmail.com
loop0: detected capacity change from 0 to 32768
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in fs/gfs2/ops_fstype.c:1172:19
shift exponent 4294967287 is too large for 64-bit type 'unsigned long'
CPU: 1 UID: 0 PID: 6127 Comm: syz.0.42 Not tainted 6.14.0-next-20250404-syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
ubsan_epilogue lib/ubsan.c:231 [inline]
__ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:492
gfs2_fill_super+0x255e/0x27b0 fs/gfs2/ops_fstype.c:1172
get_tree_bdev_flags+0x490/0x5c0 fs/super.c:1636
gfs2_get_tree+0x54/0x220 fs/gfs2/ops_fstype.c:1330
vfs_get_tree+0x90/0x2b0 fs/super.c:1759
do_new_mount+0x2cf/0xb70 fs/namespace.c:3879
do_mount fs/namespace.c:4219 [inline]
__do_sys_mount fs/namespace.c:4430 [inline]
__se_sys_mount+0x38c/0x400 fs/namespace.c:4407
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb2fa18e90a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb2fafe2e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fb2fafe2ef0 RCX: 00007fb2fa18e90a
RDX: 0000200000000400 RSI: 0000200000012500 RDI: 00007fb2fafe2eb0
RBP: 0000200000000400 R08: 00007fb2fafe2ef0 R09: 0000000000000102
R10: 0000000000000102 R11: 0000000000000246 R12: 0000200000012500
R13: 00007fb2fafe2eb0 R14: 00000000000125bb R15: 00002000000004c0
</TASK>
---[ end trace ]---
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] gfs2: capture blocksize set failed
2025-04-11 8:28 [syzbot] [gfs2?] UBSAN: shift-out-of-bounds in gfs2_fill_super syzbot
@ 2025-04-12 5:07 ` Edward Adam Davis
2025-04-12 12:24 ` Andreas Gruenbacher
0 siblings, 1 reply; 3+ messages in thread
From: Edward Adam Davis @ 2025-04-12 5:07 UTC (permalink / raw)
To: syzbot+b0018b7468b2af33b4d5; +Cc: agruenba, gfs2, linux-kernel, syzkaller-bugs
syzbot reported a oob in gfs2_fill_super. [1]
When setting blocksize fails, the s_blocksize_bits value is incorrect.
[1]
UBSAN: shift-out-of-bounds in fs/gfs2/ops_fstype.c:1172:19
shift exponent 4294967287 is too large for 64-bit type 'unsigned long'
CPU: 1 UID: 0 PID: 6127 Comm: syz.0.42 Not tainted 6.14.0-next-20250404-syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
ubsan_epilogue lib/ubsan.c:231 [inline]
__ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:492
gfs2_fill_super+0x255e/0x27b0 fs/gfs2/ops_fstype.c:1172
get_tree_bdev_flags+0x490/0x5c0 fs/super.c:1636
gfs2_get_tree+0x54/0x220 fs/gfs2/ops_fstype.c:1330
vfs_get_tree+0x90/0x2b0 fs/super.c:1759
do_new_mount+0x2cf/0xb70 fs/namespace.c:3879
do_mount fs/namespace.c:4219 [inline]
__do_sys_mount fs/namespace.c:4430 [inline]
__se_sys_mount+0x38c/0x400 fs/namespace.c:4407
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Reported-by: syzbot+b0018b7468b2af33b4d5@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/gfs2/ops_fstype.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index e83d293c3614..d5bc25164b89 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1167,6 +1167,10 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
/* Set up the buffer cache and fill in some fake block size values
to allow us to read-in the on-disk superblock. */
sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
+ if (!sdp->sd_sb.sb_bsize) {
+ error = -EINVAL;
+ goto fail_free;
+ }
sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] gfs2: capture blocksize set failed
2025-04-12 5:07 ` [PATCH] gfs2: capture blocksize set failed Edward Adam Davis
@ 2025-04-12 12:24 ` Andreas Gruenbacher
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Gruenbacher @ 2025-04-12 12:24 UTC (permalink / raw)
To: Edward Adam Davis
Cc: syzbot+b0018b7468b2af33b4d5, gfs2, linux-kernel, syzkaller-bugs
On Sat, Apr 12, 2025 at 7:16 AM Edward Adam Davis <eadavis@qq.com> wrote:
> syzbot reported a oob in gfs2_fill_super. [1]
>
> When setting blocksize fails, the s_blocksize_bits value is incorrect.
>
> [1]
> UBSAN: shift-out-of-bounds in fs/gfs2/ops_fstype.c:1172:19
> shift exponent 4294967287 is too large for 64-bit type 'unsigned long'
> CPU: 1 UID: 0 PID: 6127 Comm: syz.0.42 Not tainted 6.14.0-next-20250404-syzkaller #0 PREEMPT(full)
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:94 [inline]
> dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
> ubsan_epilogue lib/ubsan.c:231 [inline]
> __ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:492
> gfs2_fill_super+0x255e/0x27b0 fs/gfs2/ops_fstype.c:1172
> get_tree_bdev_flags+0x490/0x5c0 fs/super.c:1636
> gfs2_get_tree+0x54/0x220 fs/gfs2/ops_fstype.c:1330
> vfs_get_tree+0x90/0x2b0 fs/super.c:1759
> do_new_mount+0x2cf/0xb70 fs/namespace.c:3879
> do_mount fs/namespace.c:4219 [inline]
> __do_sys_mount fs/namespace.c:4430 [inline]
> __se_sys_mount+0x38c/0x400 fs/namespace.c:4407
> do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Reported-by: syzbot+b0018b7468b2af33b4d5@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> fs/gfs2/ops_fstype.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index e83d293c3614..d5bc25164b89 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -1167,6 +1167,10 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
> /* Set up the buffer cache and fill in some fake block size values
> to allow us to read-in the on-disk superblock. */
> sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
> + if (!sdp->sd_sb.sb_bsize) {
> + error = -EINVAL;
> + goto fail_free;
> + }
> sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
> sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
> sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
> --
> 2.43.0
Thanks for this patch.
I've made a small coding style adjustment, added a check for the
return value of sb_set_blocksize(), and I've changed the description
to:
gfs2: check sb_min_blocksize return value
Check the return value of sb_min_blocksize(): it will be 0 when the
requested block size is invalid.
In addition, check the return value of sb_set_blocksize() as well.
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-12 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 8:28 [syzbot] [gfs2?] UBSAN: shift-out-of-bounds in gfs2_fill_super syzbot
2025-04-12 5:07 ` [PATCH] gfs2: capture blocksize set failed Edward Adam Davis
2025-04-12 12:24 ` Andreas Gruenbacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox