All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
@ 2022-03-03 10:35 syzbot
  2022-03-03 11:13 ` Dongliang Mu
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2022-03-03 10:35 UTC (permalink / raw)
  To: clm, dsterba, josef, linux-btrfs, linux-kernel, syzkaller-bugs, terrelln

Hello,

syzbot found the following issue on:

HEAD commit:    2293be58d6a1 Merge tag 'trace-v5.17-rc4' of git://git.kern..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15f8b2d4700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5f28851401b410e5
dashboard link: https://syzkaller.appspot.com/bug?extid=82650a4e0ed38f218363
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=152ee696700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11739502700000

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

==================================================================
BUG: KASAN: use-after-free in btrfs_printk+0x395/0x425 fs/btrfs/super.c:244
Read of size 8 at addr ffff8880237906d8 by task udevd/3694

CPU: 1 PID: 3694 Comm: udevd Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 btrfs_printk+0x395/0x425 fs/btrfs/super.c:244
 device_list_add.cold+0xd7/0x2ed fs/btrfs/volumes.c:957
 btrfs_scan_one_device+0x4c7/0x5c0 fs/btrfs/volumes.c:1387
 btrfs_control_ioctl+0x12a/0x2d0 fs/btrfs/super.c:2409
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl fs/ioctl.c:860 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f86e0e090e7
Code: 3c 1c e8 1c ff ff ff 85 c0 79 87 49 c7 c4 ff ff ff ff 5b 5d 4c 89 e0 41 5c c3 66 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 61 9d 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffcb6ec2788 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f86e0e090e7
RDX: 00007ffcb6ec2798 RSI: 0000000090009427 RDI: 0000000000000009
RBP: 0000000000000009 R08: 000055f3f60246f0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffcb6ec37d8 R14: 000055f3f7c4fbc0 R15: 00007f86e0cac6c0
 </TASK>

Allocated by task 3672:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:524
 kmalloc_node include/linux/slab.h:604 [inline]
 kvmalloc_node+0x97/0x100 mm/util.c:580
 kvmalloc include/linux/slab.h:731 [inline]
 kvzalloc include/linux/slab.h:739 [inline]
 btrfs_mount_root+0x118/0xc10 fs/btrfs/super.c:1665
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 fc_mount fs/namespace.c:1030 [inline]
 vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
 btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 do_new_mount fs/namespace.c:3024 [inline]
 path_mount+0x1320/0x1fa0 fs/namespace.c:3354
 do_mount fs/namespace.c:3367 [inline]
 __do_sys_mount fs/namespace.c:3575 [inline]
 __se_sys_mount fs/namespace.c:3552 [inline]
 __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 3672:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0xff/0x140 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:236 [inline]
 __cache_free mm/slab.c:3437 [inline]
 kfree+0xf8/0x2b0 mm/slab.c:3794
 kvfree+0x42/0x50 mm/util.c:613
 deactivate_locked_super+0x94/0x160 fs/super.c:332
 btrfs_mount_root+0x78e/0xc10 fs/btrfs/super.c:1730
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 fc_mount fs/namespace.c:1030 [inline]
 vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
 btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 do_new_mount fs/namespace.c:3024 [inline]
 path_mount+0x1320/0x1fa0 fs/namespace.c:3354
 do_mount fs/namespace.c:3367 [inline]
 __do_sys_mount fs/namespace.c:3575 [inline]
 __se_sys_mount fs/namespace.c:3552 [inline]
 __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888023790000
 which belongs to the cache kmalloc-16k of size 16384
The buggy address is located 1752 bytes inside of
 16384-byte region [ffff888023790000, ffff888023794000)
The buggy address belongs to the page:
page:ffffea00008de400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x23790
head:ffffea00008de400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000990008 ffffea000098fe08 ffff888010c40b00
raw: 0000000000000000 ffff888023790000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x2520c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 3672, ts 53936584194, free_ts 53419420055
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
 __alloc_pages_node include/linux/gfp.h:572 [inline]
 kmem_getpages mm/slab.c:1378 [inline]
 cache_grow_begin+0x75/0x390 mm/slab.c:2584
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2957
 ____cache_alloc mm/slab.c:3040 [inline]
 ____cache_alloc mm/slab.c:3023 [inline]
 slab_alloc_node mm/slab.c:3241 [inline]
 kmem_cache_alloc_node_trace+0x49c/0x5b0 mm/slab.c:3609
 __do_kmalloc_node mm/slab.c:3631 [inline]
 __kmalloc_node+0x38/0x60 mm/slab.c:3639
 kmalloc_node include/linux/slab.h:604 [inline]
 kvmalloc_node+0x97/0x100 mm/util.c:580
 kvmalloc include/linux/slab.h:731 [inline]
 kvzalloc include/linux/slab.h:739 [inline]
 btrfs_mount_root+0x118/0xc10 fs/btrfs/super.c:1665
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 fc_mount fs/namespace.c:1030 [inline]
 vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
 btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 do_new_mount fs/namespace.c:3024 [inline]
 path_mount+0x1320/0x1fa0 fs/namespace.c:3354
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1352 [inline]
 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3404
 __put_page+0x193/0x1e0 mm/swap.c:128
 folio_put include/linux/mm.h:1199 [inline]
 put_page include/linux/mm.h:1237 [inline]
 do_exit+0x1f5f/0x2a30 kernel/exit.c:845
 do_group_exit+0xd2/0x2f0 kernel/exit.c:935
 __do_sys_exit_group kernel/exit.c:946 [inline]
 __se_sys_exit_group kernel/exit.c:944 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff888023790580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888023790600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888023790680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff888023790700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888023790780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
  2022-03-03 10:35 [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2) syzbot
@ 2022-03-03 11:13 ` Dongliang Mu
  0 siblings, 0 replies; 6+ messages in thread
From: Dongliang Mu @ 2022-03-03 11:13 UTC (permalink / raw)
  To: syzbot
  Cc: clm, David Sterba, josef, linux-btrfs, linux-kernel,
	syzkaller-bugs, terrelln

On Thu, Mar 3, 2022 at 6:35 PM syzbot
<syzbot+82650a4e0ed38f218363@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:    2293be58d6a1 Merge tag 'trace-v5.17-rc4' of git://git.kern..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=15f8b2d4700000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5f28851401b410e5
> dashboard link: https://syzkaller.appspot.com/bug?extid=82650a4e0ed38f218363
> compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=152ee696700000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11739502700000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+82650a4e0ed38f218363@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KASAN: use-after-free in btrfs_printk+0x395/0x425 fs/btrfs/super.c:244
> Read of size 8 at addr ffff8880237906d8 by task udevd/3694
>
> CPU: 1 PID: 3694 Comm: udevd Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1 #0
> Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
> Call Trace:
>  <TASK>
>  __dump_stack lib/dump_stack.c:88 [inline]
>  dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
>  print_address_description.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255
>  __kasan_report mm/kasan/report.c:442 [inline]
>  kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
>  btrfs_printk+0x395/0x425 fs/btrfs/super.c:244
>  device_list_add.cold+0xd7/0x2ed fs/btrfs/volumes.c:957

From this crashing trace, the reason is similar with commit 0697d9a61099.

Fix this by modifying another site using fs_info.

I will push a patch request later.

>  btrfs_scan_one_device+0x4c7/0x5c0 fs/btrfs/volumes.c:1387
>  btrfs_control_ioctl+0x12a/0x2d0 fs/btrfs/super.c:2409
>  vfs_ioctl fs/ioctl.c:51 [inline]
>  __do_sys_ioctl fs/ioctl.c:874 [inline]
>  __se_sys_ioctl fs/ioctl.c:860 [inline]
>  __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
>  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>  do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
> RIP: 0033:0x7f86e0e090e7
> Code: 3c 1c e8 1c ff ff ff 85 c0 79 87 49 c7 c4 ff ff ff ff 5b 5d 4c 89 e0 41 5c c3 66 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 61 9d 0c 00 f7 d8 64 89 01 48
> RSP: 002b:00007ffcb6ec2788 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f86e0e090e7
> RDX: 00007ffcb6ec2798 RSI: 0000000090009427 RDI: 0000000000000009
> RBP: 0000000000000009 R08: 000055f3f60246f0 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: 00007ffcb6ec37d8 R14: 000055f3f7c4fbc0 R15: 00007f86e0cac6c0
>  </TASK>
>
> Allocated by task 3672:
>  kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
>  kasan_set_track mm/kasan/common.c:45 [inline]
>  set_alloc_info mm/kasan/common.c:436 [inline]
>  ____kasan_kmalloc mm/kasan/common.c:515 [inline]
>  ____kasan_kmalloc mm/kasan/common.c:474 [inline]
>  __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:524
>  kmalloc_node include/linux/slab.h:604 [inline]
>  kvmalloc_node+0x97/0x100 mm/util.c:580
>  kvmalloc include/linux/slab.h:731 [inline]
>  kvzalloc include/linux/slab.h:739 [inline]
>  btrfs_mount_root+0x118/0xc10 fs/btrfs/super.c:1665
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  fc_mount fs/namespace.c:1030 [inline]
>  vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
>  vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
>  btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  do_new_mount fs/namespace.c:3024 [inline]
>  path_mount+0x1320/0x1fa0 fs/namespace.c:3354
>  do_mount fs/namespace.c:3367 [inline]
>  __do_sys_mount fs/namespace.c:3575 [inline]
>  __se_sys_mount fs/namespace.c:3552 [inline]
>  __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
>  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>  do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> Freed by task 3672:
>  kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
>  kasan_set_track+0x21/0x30 mm/kasan/common.c:45
>  kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
>  ____kasan_slab_free mm/kasan/common.c:366 [inline]
>  ____kasan_slab_free+0xff/0x140 mm/kasan/common.c:328
>  kasan_slab_free include/linux/kasan.h:236 [inline]
>  __cache_free mm/slab.c:3437 [inline]
>  kfree+0xf8/0x2b0 mm/slab.c:3794
>  kvfree+0x42/0x50 mm/util.c:613
>  deactivate_locked_super+0x94/0x160 fs/super.c:332
>  btrfs_mount_root+0x78e/0xc10 fs/btrfs/super.c:1730
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  fc_mount fs/namespace.c:1030 [inline]
>  vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
>  vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
>  btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  do_new_mount fs/namespace.c:3024 [inline]
>  path_mount+0x1320/0x1fa0 fs/namespace.c:3354
>  do_mount fs/namespace.c:3367 [inline]
>  __do_sys_mount fs/namespace.c:3575 [inline]
>  __se_sys_mount fs/namespace.c:3552 [inline]
>  __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
>  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>  do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> The buggy address belongs to the object at ffff888023790000
>  which belongs to the cache kmalloc-16k of size 16384
> The buggy address is located 1752 bytes inside of
>  16384-byte region [ffff888023790000, ffff888023794000)
> The buggy address belongs to the page:
> page:ffffea00008de400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x23790
> head:ffffea00008de400 order:3 compound_mapcount:0 compound_pincount:0
> flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
> raw: 00fff00000010200 ffffea0000990008 ffffea000098fe08 ffff888010c40b00
> raw: 0000000000000000 ffff888023790000 0000000100000001 0000000000000000
> page dumped because: kasan: bad access detected
> page_owner tracks the page as allocated
> page last allocated via order 3, migratetype Unmovable, gfp_mask 0x2520c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 3672, ts 53936584194, free_ts 53419420055
>  prep_new_page mm/page_alloc.c:2434 [inline]
>  get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
>  __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
>  __alloc_pages_node include/linux/gfp.h:572 [inline]
>  kmem_getpages mm/slab.c:1378 [inline]
>  cache_grow_begin+0x75/0x390 mm/slab.c:2584
>  cache_alloc_refill+0x27f/0x380 mm/slab.c:2957
>  ____cache_alloc mm/slab.c:3040 [inline]
>  ____cache_alloc mm/slab.c:3023 [inline]
>  slab_alloc_node mm/slab.c:3241 [inline]
>  kmem_cache_alloc_node_trace+0x49c/0x5b0 mm/slab.c:3609
>  __do_kmalloc_node mm/slab.c:3631 [inline]
>  __kmalloc_node+0x38/0x60 mm/slab.c:3639
>  kmalloc_node include/linux/slab.h:604 [inline]
>  kvmalloc_node+0x97/0x100 mm/util.c:580
>  kvmalloc include/linux/slab.h:731 [inline]
>  kvzalloc include/linux/slab.h:739 [inline]
>  btrfs_mount_root+0x118/0xc10 fs/btrfs/super.c:1665
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  fc_mount fs/namespace.c:1030 [inline]
>  vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
>  vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
>  btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1784
>  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
>  vfs_get_tree+0x89/0x2f0 fs/super.c:1497
>  do_new_mount fs/namespace.c:3024 [inline]
>  path_mount+0x1320/0x1fa0 fs/namespace.c:3354
> page last free stack trace:
>  reset_page_owner include/linux/page_owner.h:24 [inline]
>  free_pages_prepare mm/page_alloc.c:1352 [inline]
>  free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
>  free_unref_page_prepare mm/page_alloc.c:3325 [inline]
>  free_unref_page+0x19/0x690 mm/page_alloc.c:3404
>  __put_page+0x193/0x1e0 mm/swap.c:128
>  folio_put include/linux/mm.h:1199 [inline]
>  put_page include/linux/mm.h:1237 [inline]
>  do_exit+0x1f5f/0x2a30 kernel/exit.c:845
>  do_group_exit+0xd2/0x2f0 kernel/exit.c:935
>  __do_sys_exit_group kernel/exit.c:946 [inline]
>  __se_sys_exit_group kernel/exit.c:944 [inline]
>  __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944
>  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>  do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> Memory state around the buggy address:
>  ffff888023790580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>  ffff888023790600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> >ffff888023790680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>                                                     ^
>  ffff888023790700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>  ffff888023790780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
>
>
> ---
> 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.
> syzbot can test patches for this issue, for details see:
> https://goo.gl/tpsmEJ#testing-patches
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/00000000000066b78e05d94df48b%40google.com.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
       [not found] <20220304114907.2733-1-hdanton@sina.com>
@ 2022-03-04 12:09 ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2022-03-04 12:09 UTC (permalink / raw)
  To: anand.jain, dsterba, hdanton, linux-btrfs, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+82650a4e0ed38f218363@syzkaller.appspotmail.com

Tested on:

commit:         2293be58 Merge tag 'trace-v5.17-rc4' of git://git.kern..
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
kernel config:  https://syzkaller.appspot.com/x/.config?x=5f28851401b410e5
dashboard link: https://syzkaller.appspot.com/bug?extid=82650a4e0ed38f218363
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1723b521700000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
       [not found] <20220304052236.2562-1-hdanton@sina.com>
@ 2022-03-04  5:40 ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2022-03-04  5:40 UTC (permalink / raw)
  To: anand.jain, dsterba, hdanton, linux-btrfs, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in btrfs_iget

general protection fault, probably for non-canonical address 0xdffffc000000003e: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000001f0-0x00000000000001f7]
CPU: 0 PID: 3975 Comm: syz-executor324 Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:btrfs_inode_hash fs/btrfs/btrfs_inode.h:258 [inline]
RIP: 0010:btrfs_iget_locked fs/btrfs/inode.c:5503 [inline]
RIP: 0010:btrfs_iget_path fs/btrfs/inode.c:5525 [inline]
RIP: 0010:btrfs_iget+0x7a/0x210 fs/btrfs/inode.c:5554
Code: f3 65 48 8b 04 25 28 00 00 00 48 89 44 24 58 31 c0 e8 3a 5f 33 fe 49 8d be f7 01 00 00 48 89 f8 48 89 fe 48 c1 e8 03 83 e6 07 <42> 0f b6 14 20 49 8d 86 fe 01 00 00 48 89 c1 48 c1 e9 03 42 0f b6
RSP: 0018:ffffc900029ef940 EFLAGS: 00010202

RAX: 000000000000003e RBX: 1ffff9200053df28 RCX: 0000000000000000
RDX: ffff88801c40e2c0 RSI: 0000000000000007 RDI: 00000000000001f7
RBP: ffff888023dce000 R08: 0000000000000000 R09: ffffc900029ef6f7
R10: ffffffff8912a851 R11: 0000000000000001 R12: dffffc0000000000
R13: 0000000000000100 R14: 0000000000000000 R15: 0000000000000000
FS:  00007fec6fcc0700(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000563567f04618 CR3: 0000000026c41000 CR4: 0000000000150ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 btrfs_fill_super fs/btrfs/super.c:1364 [inline]
 btrfs_mount_root.cold+0x93/0x1a2 fs/btrfs/super.c:1726
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 fc_mount fs/namespace.c:1030 [inline]
 vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
 btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1788
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 do_new_mount fs/namespace.c:3024 [inline]
 path_mount+0x1320/0x1fa0 fs/namespace.c:3354
 do_mount fs/namespace.c:3367 [inline]
 __do_sys_mount fs/namespace.c:3575 [inline]
 __se_sys_mount fs/namespace.c:3552 [inline]
 __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fec6fd142a9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fec6fcc02f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fec6fd993e0 RCX: 00007fec6fd142a9
RDX: 0000000020000140 RSI: 0000000020000100 RDI: 0000000020000080
RBP: 0030656c69662f2e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007fec6fd65478
R13: 00007fec6fd651f0 R14: 00007fec6fd650a8 R15: 00007fec6fd993e8
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:btrfs_inode_hash fs/btrfs/btrfs_inode.h:258 [inline]
RIP: 0010:btrfs_iget_locked fs/btrfs/inode.c:5503 [inline]
RIP: 0010:btrfs_iget_path fs/btrfs/inode.c:5525 [inline]
RIP: 0010:btrfs_iget+0x7a/0x210 fs/btrfs/inode.c:5554
Code: f3 65 48 8b 04 25 28 00 00 00 48 89 44 24 58 31 c0 e8 3a 5f 33 fe 49 8d be f7 01 00 00 48 89 f8 48 89 fe 48 c1 e8 03 83 e6 07 <42> 0f b6 14 20 49 8d 86 fe 01 00 00 48 89 c1 48 c1 e9 03 42 0f b6
RSP: 0018:ffffc900029ef940 EFLAGS: 00010202
RAX: 000000000000003e RBX: 1ffff9200053df28 RCX: 0000000000000000
RDX: ffff88801c40e2c0 RSI: 0000000000000007 RDI: 00000000000001f7
RBP: ffff888023dce000 R08: 0000000000000000 R09: ffffc900029ef6f7
R10: ffffffff8912a851 R11: 0000000000000001 R12: dffffc0000000000
R13: 0000000000000100 R14: 0000000000000000 R15: 0000000000000000
FS:  00007fec6fcc0700(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000563567f04618 CR3: 0000000026c41000 CR4: 0000000000150ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	f3 65 48 8b 04 25 28 	repz mov %gs:0x28,%rax
   7:	00 00 00
   a:	48 89 44 24 58       	mov    %rax,0x58(%rsp)
   f:	31 c0                	xor    %eax,%eax
  11:	e8 3a 5f 33 fe       	callq  0xfe335f50
  16:	49 8d be f7 01 00 00 	lea    0x1f7(%r14),%rdi
  1d:	48 89 f8             	mov    %rdi,%rax
  20:	48 89 fe             	mov    %rdi,%rsi
  23:	48 c1 e8 03          	shr    $0x3,%rax
  27:	83 e6 07             	and    $0x7,%esi
* 2a:	42 0f b6 14 20       	movzbl (%rax,%r12,1),%edx <-- trapping instruction
  2f:	49 8d 86 fe 01 00 00 	lea    0x1fe(%r14),%rax
  36:	48 89 c1             	mov    %rax,%rcx
  39:	48 c1 e9 03          	shr    $0x3,%rcx
  3d:	42                   	rex.X
  3e:	0f                   	.byte 0xf
  3f:	b6                   	.byte 0xb6


Tested on:

commit:         2293be58 Merge tag 'trace-v5.17-rc4' of git://git.kern..
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
console output: https://syzkaller.appspot.com/x/log.txt?x=112736d6700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5f28851401b410e5
dashboard link: https://syzkaller.appspot.com/bug?extid=82650a4e0ed38f218363
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch:          https://syzkaller.appspot.com/x/patch.diff?x=11de2ad6700000


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
  2022-03-04  2:08 ` syzbot
@ 2022-03-04  3:23   ` Anand Jain
  0 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2022-03-04  3:23 UTC (permalink / raw)
  To: syzbot, dsterba, hdanton, linux-btrfs, linux-kernel, syzkaller-bugs


::
> Tested on:
> 
> commit:         2293be58 Merge tag 'trace-v5.17-rc4' of git://git.kern..
> git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
::
> patch:          https://syzkaller.appspot.com/x/patch.diff?x=133011f1700000


There is no commit id in the patch. The patch diff doesn't match any
changes in the current misc-next?

Thanks, Anand

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2)
       [not found] <20220304014317.2373-1-hdanton@sina.com>
@ 2022-03-04  2:08 ` syzbot
  2022-03-04  3:23   ` Anand Jain
  0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2022-03-04  2:08 UTC (permalink / raw)
  To: anand.jain, dsterba, hdanton, linux-btrfs, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in invalidate_bdev

general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
CPU: 1 PID: 4000 Comm: syz-executor143 Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:invalidate_bdev+0x1f/0xd0 block/bdev.c:83
Code: fe 66 2e 0f 1f 84 00 00 00 00 00 55 53 48 89 fb e8 46 02 b2 fd 48 8d 7b 30 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 93 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b
RSP: 0018:ffffc90000e07840 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000006 RSI: ffffffff83c5df9a RDI: 0000000000000030
RBP: ffff888026948000 R08: 0000000000000000 R09: ffffffff8b814683
R10: fffffbfff17028d0 R11: 0000000000000001 R12: ffff88802b5095c0
R13: 0000000000000001 R14: 0000000000000001 R15: ffff88801fb54000
FS:  00007fc526ad8700(0000) GS:ffff88802cb00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005614541cd000 CR3: 0000000022cb3000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 open_ctree+0xacf/0x4817 fs/btrfs/disk-io.c:3389
 btrfs_fill_super fs/btrfs/super.c:1358 [inline]
 btrfs_mount_root.cold+0x15/0x1a2 fs/btrfs/super.c:1726
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 fc_mount fs/namespace.c:1030 [inline]
 vfs_kern_mount.part.0+0xd3/0x170 fs/namespace.c:1060
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:1047
 btrfs_mount+0x234/0xa60 fs/btrfs/super.c:1788
 legacy_get_tree+0x105/0x220 fs/fs_context.c:610
 vfs_get_tree+0x89/0x2f0 fs/super.c:1497
 do_new_mount fs/namespace.c:3024 [inline]
 path_mount+0x1320/0x1fa0 fs/namespace.c:3354
 do_mount fs/namespace.c:3367 [inline]
 __do_sys_mount fs/namespace.c:3575 [inline]
 __se_sys_mount fs/namespace.c:3552 [inline]
 __x64_sys_mount+0x27f/0x300 fs/namespace.c:3552
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fc526b2c2a9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fc526ad82f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fc526bb13e0 RCX: 00007fc526b2c2a9
RDX: 0000000020000140 RSI: 0000000020000100 RDI: 0000000020000080
RBP: 0030656c69662f2e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007fc526b7d478
R13: 00007fc526b7d1f0 R14: 00007fc526b7d0a8 R15: 00007fc526bb13e8
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:invalidate_bdev+0x1f/0xd0 block/bdev.c:83
Code: fe 66 2e 0f 1f 84 00 00 00 00 00 55 53 48 89 fb e8 46 02 b2 fd 48 8d 7b 30 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 93 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b
RSP: 0018:ffffc90000e07840 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000006 RSI: ffffffff83c5df9a RDI: 0000000000000030
RBP: ffff888026948000 R08: 0000000000000000 R09: ffffffff8b814683
R10: fffffbfff17028d0 R11: 0000000000000001 R12: ffff88802b5095c0
R13: 0000000000000001 R14: 0000000000000001 R15: ffff88801fb54000
FS:  00007fc526ad8700(0000) GS:ffff88802cb00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005614541cd000 CR3: 0000000022cb3000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
   7:	00 00 00
   a:	55                   	push   %rbp
   b:	53                   	push   %rbx
   c:	48 89 fb             	mov    %rdi,%rbx
   f:	e8 46 02 b2 fd       	callq  0xfdb2025a
  14:	48 8d 7b 30          	lea    0x30(%rbx),%rdi
  18:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  1f:	fc ff df
  22:	48 89 fa             	mov    %rdi,%rdx
  25:	48 c1 ea 03          	shr    $0x3,%rdx
* 29:	80 3c 02 00          	cmpb   $0x0,(%rdx,%rax,1) <-- trapping instruction
  2d:	0f 85 93 00 00 00    	jne    0xc6
  33:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  3a:	fc ff df
  3d:	48                   	rex.W
  3e:	8b                   	.byte 0x8b


Tested on:

commit:         2293be58 Merge tag 'trace-v5.17-rc4' of git://git.kern..
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
console output: https://syzkaller.appspot.com/x/log.txt?x=13d047e1700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5f28851401b410e5
dashboard link: https://syzkaller.appspot.com/bug?extid=82650a4e0ed38f218363
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch:          https://syzkaller.appspot.com/x/patch.diff?x=133011f1700000


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-04 12:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 10:35 [syzbot] KASAN: use-after-free Read in btrfs_scan_one_device (2) syzbot
2022-03-03 11:13 ` Dongliang Mu
     [not found] <20220304014317.2373-1-hdanton@sina.com>
2022-03-04  2:08 ` syzbot
2022-03-04  3:23   ` Anand Jain
     [not found] <20220304052236.2562-1-hdanton@sina.com>
2022-03-04  5:40 ` syzbot
     [not found] <20220304114907.2733-1-hdanton@sina.com>
2022-03-04 12:09 ` syzbot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.