syzbot


KASAN: use-after-free Write in ex_handler_refcount (2)

Status: upstream: reported C repro on 2021/03/29 13:41
Reported-by: syzbot+a2d92f19728cc7ea347f@syzkaller.appspotmail.com
First crash: 455d, last: 5d05h

Fix bisection: failed (bisect log)
similar bugs (5):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount (2) 1 627d 627d 0/1 auto-closed as invalid on 2021/02/06 10:12
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount C done 16 664d 873d 1/1 fixed on 2020/10/03 03:40
android-54 KASAN: use-after-free Write in ex_handler_refcount syz 4 666d 668d 0/2 upstream: reported syz repro on 2020/08/29 07:49
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount (3) C 32 5d05h 492d 0/1 upstream: reported C repro on 2021/02/20 19:09
linux-4.19 KASAN: use-after-free Write in ex_handler_refcount C done 11 664d 872d 1/1 fixed on 2020/10/02 13:00

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ex_handler_refcount+0x18f/0x1c0 arch/x86/mm/extable.c:49
Write of size 4 at addr ffff8880a303fad8 by task systemd-udevd/8280

CPU: 0 PID: 8280 Comm: systemd-udevd Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_store4_noabort+0x88/0x90 mm/kasan/report.c:437
 ex_handler_refcount+0x18f/0x1c0 arch/x86/mm/extable.c:49
 fixup_exception+0x8a/0xd0 arch/x86/mm/extable.c:197
 do_trap_no_signal arch/x86/kernel/traps.c:209 [inline]
 do_trap+0x61/0x250 arch/x86/kernel/traps.c:258
 do_error_trap+0x15d/0x310 arch/x86/kernel/traps.c:303
 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:1038
RIP: 0010:__noinstr_text_end+0x243b/0x7813
Code: 0f 0b 48 8d 4b 50 0f 0b 48 8d 4b 08 0f 0b 48 8d 4d 08 0f 0b 48 8d 8d 08 02 00 00 0f 0b 48 8d 0b 0f 0b 48 8d 0b 0f 0b 48 8d 0b <0f> 0b 48 8d 4d 00 0f 0b 49 8d 0c 24 0f 0b 48 8d 8b c0 00 00 00 0f
RSP: 0018:ffff8880afee7cd8 EFLAGS: 00010296
RAX: 0000000000000000 RBX: ffff8880a303fad8 RCX: ffff8880a303fad8
RDX: 0000000000000004 RSI: 0000000000000004 RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff14b7985
R10: ffffffff8a5bcc2b R11: 0000000000000000 R12: ffffffff8a5bcc20
R13: 0000000000000000 R14: 1ffff11011610335 R15: dffffc0000000000
 nbd_put drivers/block/nbd.c:228 [inline]
 nbd_release+0x108/0x170 drivers/block/nbd.c:1462
 __blkdev_put+0x636/0x870 fs/block_dev.c:1819
 blkdev_close+0x86/0xb0 fs/block_dev.c:1888
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fa987df4270
Code: 73 01 c3 48 8b 0d 38 7d 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c1 20 00 00 75 10 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ee fb ff ff 48 89 04 24
RSP: 002b:00007ffdbb2c5df8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000007 RCX: 00007fa987df4270
RDX: 000000000aba9500 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007fa988cae710 R08: 0000000000000045 R09: 0000000000000018
R10: 000056178b36fde8 R11: 0000000000000246 R12: 0000000000000000
R13: 000056178b36b6e0 R14: 0000000000000003 R15: 000000000000000e

Allocated by task 8256:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 nbd_dev_add+0x44/0x890 drivers/block/nbd.c:1627
 nbd_genl_connect+0x4cc/0x1630 drivers/block/nbd.c:1773
 genl_family_rcv_msg+0x642/0xc40 net/netlink/genetlink.c:602
 genl_rcv_msg+0xbf/0x160 net/netlink/genetlink.c:627
 netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:638
 netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline]
 netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351
 netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xc3/0x120 net/socket.c:661
 ___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
 __sys_sendmsg net/socket.c:2265 [inline]
 __do_sys_sendmsg net/socket.c:2274 [inline]
 __se_sys_sendmsg net/socket.c:2272 [inline]
 __x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8271:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 nbd_dev_remove drivers/block/nbd.c:223 [inline]
 nbd_put.part.0+0xfe/0x140 drivers/block/nbd.c:231
 nbd_put drivers/block/nbd.c:228 [inline]
 nbd_genl_connect+0x120e/0x1630 drivers/block/nbd.c:1913
 genl_family_rcv_msg+0x642/0xc40 net/netlink/genetlink.c:602
 genl_rcv_msg+0xbf/0x160 net/netlink/genetlink.c:627
 netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:638
 netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline]
 netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351
 netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xc3/0x120 net/socket.c:661
 ___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
 __sys_sendmsg net/socket.c:2265 [inline]
 __do_sys_sendmsg net/socket.c:2274 [inline]
 __se_sys_sendmsg net/socket.c:2272 [inline]
 __x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a303fa00
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
 512-byte region [ffff8880a303fa00, ffff8880a303fc00)
The buggy address belongs to the page:
page:ffffea00028c0fc0 count:1 mapcount:0 mapping:ffff88813bff0940 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002911008 ffffea00028d2288 ffff88813bff0940
raw: 0000000000000000 ffff8880a303f000 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a303f980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a303fa00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a303fa80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8880a303fb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a303fb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (32):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2022/06/23 06:16 linux-4.19.y 3f8a27f9e27b 912f5df7 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/06/11 04:49 linux-4.19.y 3f8a27f9e27b 0d5abf15 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/05/20 18:32 linux-4.19.y 3f8a27f9e27b bd37ad7e .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/02/07 11:39 linux-4.19.y 3f8a27f9e27b a7dab638 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/05/21 12:09 linux-4.19.y 3c8c23092588 3c7fef33 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/05/15 01:39 linux-4.19.y 3c8c23092588 8bdd5343 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/05/14 07:43 linux-4.19.y 3c8c23092588 8bdd5343 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/05/12 12:45 linux-4.19.y 3c8c23092588 86294427 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/05/08 18:14 linux-4.19.y 3c8c23092588 bc5434be .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/04/25 16:19 linux-4.19.y 2965db2e004c 36c88236 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/04/15 04:05 linux-4.19.y 0f1b4cb77d7f fcdb12ba .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/04/14 13:14 linux-4.19.y 0f1b4cb77d7f 3134b37f .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/03/29 13:40 linux-4.19.y 78fec1611cbf a8529b82 .config log report syz C KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/06/16 13:35 linux-4.19.y 3f8a27f9e27b 1719ee24 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/06/15 19:58 linux-4.19.y 3f8a27f9e27b 1719ee24 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/05/11 05:27 linux-4.19.y 3f8a27f9e27b 8d7b3b67 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/04/29 00:58 linux-4.19.y 3f8a27f9e27b e9076525 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/04/22 06:51 linux-4.19.y 3f8a27f9e27b 2738b391 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/04/20 07:42 linux-4.19.y 3f8a27f9e27b 7d7bc738 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/04/17 18:21 linux-4.19.y 3f8a27f9e27b 8bcc32a6 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/03/07 05:24 linux-4.19.y 3f8a27f9e27b 7bdd8b2c .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/02/25 10:40 linux-4.19.y 3f8a27f9e27b 7c337266 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/02/17 16:00 linux-4.19.y 3f8a27f9e27b 2bea8a27 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/02/12 19:32 linux-4.19.y 3f8a27f9e27b 8b9ca619 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/02/09 17:20 linux-4.19.y 3f8a27f9e27b 0b33604d .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/01/19 22:26 linux-4.19.y 3f8a27f9e27b 5da9499f .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/01/18 03:02 linux-4.19.y 3f8a27f9e27b 731a2d23 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2022/01/14 20:47 linux-4.19.y 3f8a27f9e27b 53e00b45 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/12/24 00:33 linux-4.19.y 3f8a27f9e27b 6caa12e4 .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/12/08 05:33 linux-4.19.y 3f8a27f9e27b 0230ba3e .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/10/21 08:32 linux-4.19.y 3f8a27f9e27b f111d03b .config log report info KASAN: use-after-free Write in ex_handler_refcount
ci2-linux-4-19 2021/07/21 07:23 linux-4.19.y 4938296e03bd 1b201b48 .config log report info KASAN: use-after-free Write in ex_handler_refcount