syzbot


KASAN: use-after-free Read in delete_partition (2)

Status: fixed on 2023/04/12 21:18
Subsystems: block
[Documentation on labels]
Reported-by: syzbot+7d6c5587ec9cff5be65c@syzkaller.appspotmail.com
Fix commit: b5cfbd35ecca block: check disk exist before trying to add partition
First crash: 1348d, last: 1348d
Cause bisection: introduced by (bisect log) :
commit daaedb820ad716e00210af8859b194c404202b78
Author: Christoph Hellwig <hch@lst.de>
Date: Tue Nov 3 10:00:09 2020 +0000

  mtd_blkdevs: don't override BLKFLSBUF

Crash: BUG: sleeping function called from invalid context in sta_info_move_state (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH] block: Avoid accessing an already freed kobject in delete_partition 5 (5) 2021/07/06 06:28
[syzbot] KASAN: use-after-free Read in delete_partition (2) 0 (1) 2021/03/30 21:45
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in delete_partition block C done done 3 1558d 1555d 15/28 fixed on 2020/11/16 12:12
Last patch testing requests (6)
Created Duration User Patch Repo Result
2023/01/15 09:32 21m retest repro linux-next error
2022/10/02 07:30 17m retest repro linux-next error
2021/07/02 21:54 18m rajatasthana4@gmail.com patch upstream OK
2021/06/29 22:58 19m rajatasthana4@gmail.com patch upstream OK
2021/06/25 20:34 18m rajatasthana4@gmail.com upstream report log
2021/06/25 20:29 18m rajatasthana4@gmail.com https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in kobject_put+0x493/0x540 lib/kobject.c:749
Read of size 1 at addr ffff8880135d453c by task syz-executor372/8533

CPU: 0 PID: 8533 Comm: syz-executor372 Not tainted 5.12.0-rc4-next-20210326-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
 __kasan_report mm/kasan/report.c:399 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
 kobject_put+0x493/0x540 lib/kobject.c:749
 delete_partition+0xa4/0x170 block/partitions/core.c:291
 bdev_del_partition+0xf5/0x110 block/partitions/core.c:474
 blkpg_do_ioctl+0x2e8/0x340 block/ioctl.c:33
 blkpg_ioctl block/ioctl.c:60 [inline]
 blkdev_ioctl+0x577/0x6d0 block/ioctl.c:548
 block_ioctl+0xf9/0x140 fs/block_dev.c:1667
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x444329
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 14 00 00 90 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdd8945e58 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000487072 RCX: 0000000000444329
RDX: 0000000020000240 RSI: 0000000000001269 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0023706f6f6c2f76 R09: 0000000000000001
R10: 000000000000001f R11: 0000000000000246 R12: 0000000000012734
R13: 00007ffdd8945e6c R14: 00007ffdd8945e80 R15: 00007ffdd8945e70

Allocated by task 8534:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc mm/kasan/common.c:507 [inline]
 ____kasan_kmalloc mm/kasan/common.c:466 [inline]
 __kasan_kmalloc+0x9b/0xd0 mm/kasan/common.c:516
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:686 [inline]
 kobject_create lib/kobject.c:784 [inline]
 kobject_create_and_add+0x42/0xb0 lib/kobject.c:810
 add_partition+0x56c/0x880 block/partitions/core.c:384
 bdev_add_partition+0xb6/0x130 block/partitions/core.c:449
 blkpg_do_ioctl+0x2d0/0x340 block/ioctl.c:43
 blkpg_ioctl block/ioctl.c:60 [inline]
 blkdev_ioctl+0x577/0x6d0 block/ioctl.c:548
 block_ioctl+0xf9/0x140 fs/block_dev.c:1667
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 8534:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357
 ____kasan_slab_free mm/kasan/common.c:360 [inline]
 ____kasan_slab_free mm/kasan/common.c:325 [inline]
 __kasan_slab_free+0xfb/0x130 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:212 [inline]
 slab_free_hook mm/slub.c:1578 [inline]
 slab_free_freelist_hook+0xdf/0x240 mm/slub.c:1603
 slab_free mm/slub.c:3163 [inline]
 kfree+0xe5/0x7f0 mm/slub.c:4230
 kobject_cleanup lib/kobject.c:705 [inline]
 kobject_release lib/kobject.c:736 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x540 lib/kobject.c:753
 delete_partition+0xa4/0x170 block/partitions/core.c:291
 bdev_del_partition+0xf5/0x110 block/partitions/core.c:474
 blkpg_do_ioctl+0x2e8/0x340 block/ioctl.c:33
 blkpg_ioctl block/ioctl.c:60 [inline]
 blkdev_ioctl+0x577/0x6d0 block/ioctl.c:548
 block_ioctl+0xf9/0x140 fs/block_dev.c:1667
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff8880135d4500
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 60 bytes inside of
 64-byte region [ffff8880135d4500, ffff8880135d4540)
The buggy address belongs to the page:
page:ffffea00004d7500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x135d4
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 0000000100000001 ffff888010841640
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880135d4400: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880135d4480: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880135d4500: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                                        ^
 ffff8880135d4580: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8880135d4600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/03/30 04:55 linux-next 931294922e65 6a81331a .config console log report syz C ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in delete_partition
* Struck through repros no longer work on HEAD.