[v5.15] KASAN: null-ptr-deref Write in btrfs_root_node (2)

0 views
Skip to first unread message

syzbot

unread,
Sep 18, 2023, 12:35:00 AM9/18/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: aff03380bda4 Linux 5.15.131
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11c0e818680000
kernel config: https://syzkaller.appspot.com/x/.config?x=deb2c375928f6168
dashboard link: https://syzkaller.appspot.com/bug?extid=7ebc8dec95aca3c556de
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a1b31fbb7be5/disk-aff03380.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/13a2ea527c11/vmlinux-aff03380.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc6620249c65/Image-aff03380.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7ebc8d...@syzkaller.appspotmail.com

BTRFS info (device loop2): clearing compat-ro feature flag for FREE_SPACE_TREE (0x1)
BTRFS info (device loop2): clearing compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2)
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: null-ptr-deref in atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:577 [inline]
BUG: KASAN: null-ptr-deref in btrfs_root_node+0x144/0x404 fs/btrfs/ctree.c:138
Write of size 4 at addr 0000000000000060 by task syz-executor.2/14464

CPU: 0 PID: 14464 Comm: syz-executor.2 Not tainted 5.15.131-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
__kasan_report mm/kasan/report.c:438 [inline]
kasan_report+0x168/0x1e4 mm/kasan/report.c:451
kasan_check_range+0x274/0x2b4 mm/kasan/generic.c:189
__kasan_check_write+0x44/0x54 mm/kasan/shadow.c:37
instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:577 [inline]
btrfs_root_node+0x144/0x404 fs/btrfs/ctree.c:138
btrfs_read_lock_root_node+0x68/0x344 fs/btrfs/locking.c:276
btrfs_search_slot_get_root fs/btrfs/ctree.c:1621 [inline]
btrfs_search_slot+0x3d0/0x24d8 fs/btrfs/ctree.c:1779
btrfs_orphan_cleanup+0x1c8/0xa98 fs/btrfs/inode.c:3534
btrfs_cleanup_fs_roots+0x5e0/0x860 fs/btrfs/disk-io.c:4296
btrfs_start_pre_rw_mount+0x150/0x578 fs/btrfs/disk-io.c:3093
open_ctree+0x2258/0x288c fs/btrfs/disk-io.c:3625
btrfs_fill_super+0x1b4/0x2c8 fs/btrfs/super.c:1387
btrfs_mount_root+0x6f8/0x7f8 fs/btrfs/super.c:1752
legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
vfs_get_tree+0x90/0x274 fs/super.c:1517
fc_mount fs/namespace.c:1000 [inline]
vfs_kern_mount+0xdc/0x178 fs/namespace.c:1030
btrfs_mount+0x328/0x9b8 fs/btrfs/super.c:1812
legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
vfs_get_tree+0x90/0x274 fs/super.c:1517
do_new_mount+0x25c/0x8c4 fs/namespace.c:2994
path_mount+0x590/0x104c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
==================================================================
Unable to handle kernel paging request at virtual address dfff80000000000c
Mem abort info:
ESR = 0x0000000096000006
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x06: level 2 translation fault
Data abort info:
ISV = 0, ISS = 0x00000006
CM = 0, WnR = 0
[dfff80000000000c] address between user and kernel address ranges
Internal error: Oops: 96000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 14464 Comm: syz-executor.2 Tainted: G B 5.15.131-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : arch_atomic_fetch_add_unless include/linux/atomic/atomic-arch-fallback.h:1172 [inline]
pc : arch_atomic_add_unless include/linux/atomic/atomic-arch-fallback.h:1197 [inline]
pc : arch_atomic_inc_not_zero include/linux/atomic/atomic-arch-fallback.h:1213 [inline]
pc : atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:578 [inline]
pc : btrfs_root_node+0x148/0x404 fs/btrfs/ctree.c:138
lr : instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
lr : atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:577 [inline]
lr : btrfs_root_node+0x144/0x404 fs/btrfs/ctree.c:138
sp : ffff800020606de0
x29: ffff800020606de0 x28: dfff800000000000 x27: ffff800011e77480
x26: 0000000000000060 x25: 0000000000000000 x24: 1fffe0001afd8000
x23: ffff800011e77a80 x22: 0000000000000001 x21: 0000000000000001
x20: ffff800011e77480 x19: ffff0000d7ec0000 x18: 1fffe000368fef8e
x17: 1fffe000368fef8e x16: ffff800011963a04 x15: ffff80001499f160
x14: ffff0001b47f7c80 x13: ffffffffffffffff x12: 0000000000040000
x11: 000000000003ffff x10: ffff80002294a000 x9 : 0000000000000000
x8 : 000000000000000c x7 : 0000000000000000 x6 : ffff800008268a28
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000819b810
x2 : 0000000000000001 x1 : 0000000000000001 x0 : 0000000000000000
Call trace:
arch_atomic_fetch_add_unless include/linux/atomic/atomic-arch-fallback.h:1172 [inline]
arch_atomic_add_unless include/linux/atomic/atomic-arch-fallback.h:1197 [inline]
arch_atomic_inc_not_zero include/linux/atomic/atomic-arch-fallback.h:1213 [inline]
atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:578 [inline]
btrfs_root_node+0x148/0x404 fs/btrfs/ctree.c:138
btrfs_read_lock_root_node+0x68/0x344 fs/btrfs/locking.c:276
btrfs_search_slot_get_root fs/btrfs/ctree.c:1621 [inline]
btrfs_search_slot+0x3d0/0x24d8 fs/btrfs/ctree.c:1779
btrfs_orphan_cleanup+0x1c8/0xa98 fs/btrfs/inode.c:3534
btrfs_cleanup_fs_roots+0x5e0/0x860 fs/btrfs/disk-io.c:4296
btrfs_start_pre_rw_mount+0x150/0x578 fs/btrfs/disk-io.c:3093
open_ctree+0x2258/0x288c fs/btrfs/disk-io.c:3625
btrfs_fill_super+0x1b4/0x2c8 fs/btrfs/super.c:1387
btrfs_mount_root+0x6f8/0x7f8 fs/btrfs/super.c:1752
legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
vfs_get_tree+0x90/0x274 fs/super.c:1517
fc_mount fs/namespace.c:1000 [inline]
vfs_kern_mount+0xdc/0x178 fs/namespace.c:1030
btrfs_mount+0x328/0x9b8 fs/btrfs/super.c:1812
legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
vfs_get_tree+0x90/0x274 fs/super.c:1517
do_new_mount+0x25c/0x8c4 fs/namespace.c:2994
path_mount+0x590/0x104c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
Code: aa1a03e0 aa1b03f4 97a4ccf3 d343ff48 (38fc6908)
---[ end trace 9220ff0b280bd0db ]---
----------------
Code disassembly (best guess):
0: aa1a03e0 mov x0, x26
4: aa1b03f4 mov x20, x27
8: 97a4ccf3 bl 0xfffffffffe9333d4
c: d343ff48 lsr x8, x26, #3
* 10: 38fc6908 ldrsb w8, [x8, x28] <-- trapping instruction


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Sep 18, 2023, 12:50:02 AM9/18/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: aff03380bda4 Linux 5.15.131
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13e44818680000
kernel config: https://syzkaller.appspot.com/x/.config?x=deb2c375928f6168
dashboard link: https://syzkaller.appspot.com/bug?extid=7ebc8dec95aca3c556de
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=130cf762680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15cf1f62680000
mounted in repro: https://storage.googleapis.com/syzbot-assets/46cb1907d1db/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7ebc8d...@syzkaller.appspotmail.com

BTRFS info (device loop0): clearing compat-ro feature flag for FREE_SPACE_TREE (0x1)
BTRFS info (device loop0): clearing compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2)
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: null-ptr-deref in atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:577 [inline]
BUG: KASAN: null-ptr-deref in btrfs_root_node+0x144/0x404 fs/btrfs/ctree.c:138
Write of size 4 at addr 0000000000000060 by task syz-executor312/3970

CPU: 1 PID: 3970 Comm: syz-executor312 Not tainted 5.15.131-syzkaller #0
CPU: 1 PID: 3970 Comm: syz-executor312 Tainted: G B 5.15.131-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : arch_atomic_fetch_add_unless include/linux/atomic/atomic-arch-fallback.h:1172 [inline]
pc : arch_atomic_add_unless include/linux/atomic/atomic-arch-fallback.h:1197 [inline]
pc : arch_atomic_inc_not_zero include/linux/atomic/atomic-arch-fallback.h:1213 [inline]
pc : atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:578 [inline]
pc : btrfs_root_node+0x148/0x404 fs/btrfs/ctree.c:138
lr : instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
lr : atomic_inc_not_zero include/linux/atomic/atomic-instrumented.h:577 [inline]
lr : btrfs_root_node+0x144/0x404 fs/btrfs/ctree.c:138
sp : ffff80001ca16de0
x29: ffff80001ca16de0 x28: dfff800000000000 x27: ffff800011e77480
x26: 0000000000000060 x25: 0000000000000000 x24: 1fffe00019182400
x23: ffff800011e77a80 x22: 0000000000000001 x21: 0000000000000001
x20: ffff800011e77480 x19: ffff0000c8c12000 x18: 1fffe00036902f8e
x17: 1fffe00036902f8e x16: ffff800011963a04 x15: ffff80001499f160
x14: ffff0001b4817c80 x13: ffffffffffffffff x12: 0000000000000000
x11: ff8080000819b844 x10: 0000000000000000 x9 : 0000000000000000
---[ end trace da0241ca09b14546 ]---
----------------
Code disassembly (best guess):
0: aa1a03e0 mov x0, x26
4: aa1b03f4 mov x20, x27
8: 97a4ccf3 bl 0xfffffffffe9333d4
c: d343ff48 lsr x8, x26, #3
* 10: 38fc6908 ldrsb w8, [x8, x28] <-- trapping instruction


---
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.

syzbot

unread,
Jan 9, 2024, 1:17:09 PMJan 9
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit 745806fb4554f334e6406fa82b328562aa48f08f
git tree: upstream
Author: Qu Wenruo <w...@suse.com>
Date: Sun Jun 11 00:09:13 2023 +0000

btrfs: do not ASSERT() on duplicated global roots

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=127b4dade80000
kernel config: https://syzkaller.appspot.com/x/.config?x=dc70d39e176dd118
dashboard link: https://syzkaller.appspot.com/bug?extid=7ebc8dec95aca3c556de
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13b6e8fee80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15e3779de80000


Please keep in mind that other backports might be required as well.

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages