* [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
@ 2024-09-26 4:02 syzbot
2024-09-27 2:53 ` Zhao Mengmeng
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: syzbot @ 2024-09-26 4:02 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 1ec6d097897a Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14c0b080580000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12e58e07980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12c0b080580000
Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7bc7510fe41f/non_bootable_disk-1ec6d097.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0b74fa2b2b4e/vmlinux-1ec6d097.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1ed852a3c5d1/bzImage-1ec6d097.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/19c2305bd0ee/mount_0.gz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
bcachefs (loop0): Doing compatible version upgrade from 1.7: mi_btree_bitmap to 1.12: rebalance_work_acct_fix
running recovery passes: check_allocations
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in fs/bcachefs/ec.c:147:2
shift exponent 108 is too large for 32-bit type 'unsigned int'
CPU: 0 UID: 0 PID: 5088 Comm: syz-executor278 Not tainted 6.11.0-syzkaller-08068-g1ec6d097897a #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:93 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
ubsan_epilogue lib/ubsan.c:231 [inline]
__ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:468
bch2_stripe_to_text+0x899/0x8c0 fs/bcachefs/ec.c:147
__bch2_bkey_fsck_err+0x11f/0x230 fs/bcachefs/error.c:429
bch2_stripe_validate+0x3ca/0x630 fs/bcachefs/ec.c:116
bch2_btree_node_read_done+0x3dc6/0x5d60 fs/bcachefs/btree_io.c:1219
btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1323
bch2_btree_node_read+0x2433/0x2a10
__bch2_btree_root_read fs/bcachefs/btree_io.c:1749 [inline]
bch2_btree_root_read+0x626/0x980 fs/bcachefs/btree_io.c:1773
read_btree_roots+0x296/0x840 fs/bcachefs/recovery.c:523
bch2_fs_recovery+0x24ac/0x38b0 fs/bcachefs/recovery.c:851
bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1036
bch2_fs_get_tree+0xd61/0x1700 fs/bcachefs/fs.c:1956
vfs_get_tree+0x90/0x2b0 fs/super.c:1800
do_new_mount+0x2be/0xb40 fs/namespace.c:3507
do_mount fs/namespace.c:3847 [inline]
__do_sys_mount fs/namespace.c:4055 [inline]
__se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4032
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbcc7b8a8fa
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 5e 04 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc0febe3f8 EFLAGS: 00000282 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffc0febe410 RCX: 00007fbcc7b8a8fa
RDX: 0000000020005d80 RSI: 0000000020005dc0 RDI: 00007ffc0febe410
RBP: 0000000000000004 R08: 00007ffc0febe450 R09: 0000000000005d9a
R10: 0000000000200400 R11: 0000000000000282 R12: 0000000000200400
R13: 00007ffc0febe450 R14: 0000000000000003 R15: 0000000001000000
</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 syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
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] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
@ 2024-09-27 2:53 ` Zhao Mengmeng
2024-09-27 3:15 ` syzbot
2024-09-27 3:39 ` Zhao Mengmeng
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-09-27 2:53 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
[-- Attachment #2: test.patch --]
[-- Type: text/x-patch, Size: 552 bytes --]
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 141a4c63142f..c717d80fdfd6 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -144,7 +144,8 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c,
nr_data,
s.nr_redundant);
bch2_prt_csum_type(out, s.csum_type);
- prt_printf(out, " gran %u", 1U << s.csum_granularity_bits);
+ prt_printf(out, " gran bit %u, max gran bit %u",
+ s.csum_granularity_bits, U8_MAX);
for (unsigned i = 0; i < s.nr_blocks; i++) {
const struct bch_extent_ptr *ptr = sp->ptrs + i;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-27 2:53 ` Zhao Mengmeng
@ 2024-09-27 3:15 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-09-27 3:15 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomzhao
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=13ffe59f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=151daaa9980000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
2024-09-27 2:53 ` Zhao Mengmeng
@ 2024-09-27 3:39 ` Zhao Mengmeng
2024-09-27 4:00 ` syzbot
2024-09-27 4:43 ` Zhao Mengmeng
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-09-27 3:39 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
[-- Attachment #2: test.patch --]
[-- Type: text/x-patch, Size: 520 bytes --]
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 141a4c63142f..2d5cd9d837f2 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -144,7 +144,7 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c,
nr_data,
s.nr_redundant);
bch2_prt_csum_type(out, s.csum_type);
- prt_printf(out, " gran %u", 1U << s.csum_granularity_bits);
+ prt_printf(out, " gran 1<<%u", s.csum_granularity_bits);
for (unsigned i = 0; i < s.nr_blocks; i++) {
const struct bch_extent_ptr *ptr = sp->ptrs + i;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-27 3:39 ` Zhao Mengmeng
@ 2024-09-27 4:00 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-09-27 4:00 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomzhao
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
BUG: Bad rss-counter state
BUG: Bad rss-counter state mm:ffff8880121d0980 type:MM_SWAPENTS val:2
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=136e4507980000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=13564507980000
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
2024-09-27 2:53 ` Zhao Mengmeng
2024-09-27 3:39 ` Zhao Mengmeng
@ 2024-09-27 4:43 ` Zhao Mengmeng
2024-09-27 5:04 ` syzbot
2024-10-08 8:12 ` Zhao Mengmeng
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-09-27 4:43 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
[-- Attachment #2: test.patch --]
[-- Type: text/x-patch, Size: 520 bytes --]
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 141a4c63142f..2d5cd9d837f2 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -144,7 +144,7 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c,
nr_data,
s.nr_redundant);
bch2_prt_csum_type(out, s.csum_type);
- prt_printf(out, " gran %u", 1U << s.csum_granularity_bits);
+ prt_printf(out, " gran 1<<%u", s.csum_granularity_bits);
for (unsigned i = 0; i < s.nr_blocks; i++) {
const struct bch_extent_ptr *ptr = sp->ptrs + i;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-27 4:43 ` Zhao Mengmeng
@ 2024-09-27 5:04 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-09-27 5:04 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomengmeng
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=11e94507980000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1503f627980000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
` (2 preceding siblings ...)
2024-09-27 4:43 ` Zhao Mengmeng
@ 2024-10-08 8:12 ` Zhao Mengmeng
2024-10-08 8:29 ` syzbot
2024-10-08 8:14 ` Zhao Mengmeng
2024-10-09 3:27 ` Zhao Mengmeng
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-10-08 8:12 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
` (3 preceding siblings ...)
2024-10-08 8:12 ` Zhao Mengmeng
@ 2024-10-08 8:14 ` Zhao Mengmeng
2024-10-08 8:50 ` syzbot
2024-10-09 3:27 ` Zhao Mengmeng
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-10-08 8:14 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
[-- Attachment #2: test_2.patch --]
[-- Type: text/x-patch, Size: 1061 bytes --]
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 141a4c63142f..0801db97394e 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -113,6 +113,12 @@ int bch2_stripe_validate(struct bch_fs *c, struct bkey_s_c k,
const struct bch_stripe *s = bkey_s_c_to_stripe(k).v;
int ret = 0;
+ if (s->csum_granularity_bits >= 32) {
+ bch_err(c, "stripe csum gran bits too big (%u)",
+ s->csum_granularity_bits);
+ return -BCH_ERR_stripe_csum_granularity_bits_too_big;
+ }
+
bkey_fsck_err_on(bkey_eq(k.k->p, POS_MIN) ||
bpos_gt(k.k->p, POS(0, U32_MAX)),
c, stripe_pos_bad,
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index 742dcdd3e5d7..14ba6bc7a029 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -258,7 +258,8 @@
x(BCH_ERR_nopromote, nopromote_no_writes) \
x(BCH_ERR_nopromote, nopromote_enomem) \
x(0, invalid_snapshot_node) \
- x(0, option_needs_open_fs)
+ x(0, option_needs_open_fs) \
+ x(EINVAL, stripe_csum_granularity_bits_too_big)
enum bch_errcode {
BCH_ERR_START = 2048,
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-10-08 8:12 ` Zhao Mengmeng
@ 2024-10-08 8:29 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-10-08 8:29 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomzhao
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
UBSAN: shift-out-of-bounds in bch2_stripe_to_text
bcachefs (loop0): Doing compatible version upgrade from 1.7: mi_btree_bitmap to 1.12: rebalance_work_acct_fix
running recovery passes: check_allocations
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in fs/bcachefs/ec.c:147:2
shift exponent 108 is too large for 32-bit type 'unsigned int'
CPU: 0 UID: 0 PID: 5588 Comm: syz.0.15 Not tainted 6.11.0-syzkaller-08068-g1ec6d097897a-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:93 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
ubsan_epilogue lib/ubsan.c:231 [inline]
__ubsan_handle_shift_out_of_bounds+0x3c8/0x420 lib/ubsan.c:468
bch2_stripe_to_text+0x899/0x8c0 fs/bcachefs/ec.c:147
__bch2_bkey_fsck_err+0x11f/0x230 fs/bcachefs/error.c:429
bch2_stripe_validate+0x3ca/0x630 fs/bcachefs/ec.c:116
bch2_btree_node_read_done+0x3dc6/0x5d60 fs/bcachefs/btree_io.c:1219
btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1323
bch2_btree_node_read+0x2433/0x2a10
__bch2_btree_root_read fs/bcachefs/btree_io.c:1749 [inline]
bch2_btree_root_read+0x626/0x980 fs/bcachefs/btree_io.c:1773
read_btree_roots+0x296/0x840 fs/bcachefs/recovery.c:523
bch2_fs_recovery+0x24ac/0x38b0 fs/bcachefs/recovery.c:851
bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1036
bch2_fs_get_tree+0xd61/0x1700 fs/bcachefs/fs.c:1956
vfs_get_tree+0x90/0x2b0 fs/super.c:1800
do_new_mount+0x2be/0xb40 fs/namespace.c:3507
do_mount fs/namespace.c:3847 [inline]
__do_sys_mount fs/namespace.c:4055 [inline]
__se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4032
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f862b97f69a
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:00007f862c6a0e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f862c6a0ef0 RCX: 00007f862b97f69a
RDX: 0000000020005d80 RSI: 0000000020005dc0 RDI: 00007f862c6a0eb0
RBP: 0000000020005d80 R08: 00007f862c6a0ef0 R09: 0000000000200400
R10: 0000000000200400 R11: 0000000000000246 R12: 0000000020005dc0
R13: 00007f862c6a0eb0 R14: 0000000000005da0 R15: 0000000020000340
</TASK>
---[ end trace ]---
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=132dbb80580000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
Note: no patches were applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-10-08 8:14 ` Zhao Mengmeng
@ 2024-10-08 8:50 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-10-08 8:50 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomzhao
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=140617d0580000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1105a327980000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
` (4 preceding siblings ...)
2024-10-08 8:14 ` Zhao Mengmeng
@ 2024-10-09 3:27 ` Zhao Mengmeng
2024-10-09 3:50 ` syzbot
5 siblings, 1 reply; 13+ messages in thread
From: Zhao Mengmeng @ 2024-10-09 3:27 UTC (permalink / raw)
To: syzbot+f8c98a50c323635be65d
Cc: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1ec6d097897a
[-- Attachment #2: 0001-bcachefs-Fix-shift-out-of-bounds-in-bch2_stripe_to_t.patch --]
[-- Type: text/x-patch, Size: 2160 bytes --]
From fd481965777d8a4fa677ec8318d2562737b2d745 Mon Sep 17 00:00:00 2001
From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
Date: Wed, 9 Oct 2024 11:18:04 +0800
Subject: [PATCH] bcachefs: Fix shift-out-of-bounds in bch2_stripe_to_text
syzbot report a shift-out-of-bounds issue:
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in fs/bcachefs/ec.c:147:2
shift exponent 108 is too large for 32-bit type 'unsigned int'
----
Here s.csum_granularity_bits = 108, so shift is impossible for unsigned
int. To fix, add a check in bch2_stripe_validate() to bail out, it has
same checking logic with ec_stripe_key_init().
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
Suggested-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
---
fs/bcachefs/ec.c | 6 ++++++
fs/bcachefs/errcode.h | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 141a4c63142f..bc5ff1331c6f 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -113,6 +113,12 @@ int bch2_stripe_validate(struct bch_fs *c, struct bkey_s_c k,
const struct bch_stripe *s = bkey_s_c_to_stripe(k).v;
int ret = 0;
+ if (s->csum_granularity_bits >= ilog2(le16_to_cpu(s->sectors))) {
+ bch_err_ratelimited(c, "stripe csum gran bits %u too big",
+ s->csum_granularity_bits);
+ return -BCH_ERR_stripe_csum_granularity_bits_too_big;
+ }
+
bkey_fsck_err_on(bkey_eq(k.k->p, POS_MIN) ||
bpos_gt(k.k->p, POS(0, U32_MAX)),
c, stripe_pos_bad,
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index 742dcdd3e5d7..14ba6bc7a029 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -258,7 +258,8 @@
x(BCH_ERR_nopromote, nopromote_no_writes) \
x(BCH_ERR_nopromote, nopromote_enomem) \
x(0, invalid_snapshot_node) \
- x(0, option_needs_open_fs)
+ x(0, option_needs_open_fs) \
+ x(EINVAL, stripe_csum_granularity_bits_too_big)
enum bch_errcode {
BCH_ERR_START = 2048,
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text
2024-10-09 3:27 ` Zhao Mengmeng
@ 2024-10-09 3:50 ` syzbot
0 siblings, 0 replies; 13+ messages in thread
From: syzbot @ 2024-10-09 3:50 UTC (permalink / raw)
To: kent.overstreet, linux-bcachefs, linux-kernel, syzkaller-bugs,
zhaomzhao
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested-by: syzbot+f8c98a50c323635be65d@syzkaller.appspotmail.com
Tested on:
commit: 1ec6d097 Merge tag 's390-6.12-1' of git://git.kernel.o..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1144f707980000
kernel config: https://syzkaller.appspot.com/x/.config?x=6265dd30e362bb47
dashboard link: https://syzkaller.appspot.com/bug?extid=f8c98a50c323635be65d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1087e327980000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-10-09 3:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 4:02 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_stripe_to_text syzbot
2024-09-27 2:53 ` Zhao Mengmeng
2024-09-27 3:15 ` syzbot
2024-09-27 3:39 ` Zhao Mengmeng
2024-09-27 4:00 ` syzbot
2024-09-27 4:43 ` Zhao Mengmeng
2024-09-27 5:04 ` syzbot
2024-10-08 8:12 ` Zhao Mengmeng
2024-10-08 8:29 ` syzbot
2024-10-08 8:14 ` Zhao Mengmeng
2024-10-08 8:50 ` syzbot
2024-10-09 3:27 ` Zhao Mengmeng
2024-10-09 3:50 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox