syzbot


KASAN: use-after-free Write in xp_put_pool

Status: fixed on 2020/11/16 12:12
Subsystems: bpf net
[Documentation on labels]
Reported-by: syzbot+5334f62e4d22804e646a@syzkaller.appspotmail.com
Fix commit: 83cf5c68d663 xsk: Fix use-after-free in failed shared_umem bind
First crash: 1361d, last: 1339d
Cause bisection: introduced by (bisect log) :
commit a1132430c2c55af62d13e9fca752d46f14d548b3
Author: Magnus Karlsson <magnus.karlsson@intel.com>
Date: Fri Aug 28 08:26:26 2020 +0000

  xsk: Add shared umem support between devices

Crash: WARNING: refcount bug in __sk_destruct (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH bpf-next] xsk: fix use-after-free in failed shared_umem bind 2 (2) 2020/09/02 21:43
KASAN: use-after-free Write in xp_put_pool 3 (4) 2020/09/02 07:07

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline]
BUG: KASAN: use-after-free in refcount_sub_and_test include/linux/refcount.h:266 [inline]
BUG: KASAN: use-after-free in refcount_dec_and_test include/linux/refcount.h:294 [inline]
BUG: KASAN: use-after-free in xp_put_pool+0x2c/0x1e0 net/xdp/xsk_buff_pool.c:262
Write of size 4 at addr ffff8880a6a4d860 by task ksoftirqd/0/9

CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.9.0-rc1-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+0x18f/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 check_memory_region_inline mm/kasan/generic.c:186 [inline]
 check_memory_region+0x13d/0x180 mm/kasan/generic.c:192
 instrument_atomic_write include/linux/instrumented.h:71 [inline]
 atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline]
 refcount_sub_and_test include/linux/refcount.h:266 [inline]
 refcount_dec_and_test include/linux/refcount.h:294 [inline]
 xp_put_pool+0x2c/0x1e0 net/xdp/xsk_buff_pool.c:262
 xsk_destruct+0x7d/0xa0 net/xdp/xsk.c:1138
 __sk_destruct+0x4b/0x860 net/core/sock.c:1764
 rcu_do_batch kernel/rcu/tree.c:2428 [inline]
 rcu_core+0x5c7/0x1190 kernel/rcu/tree.c:2656
 __do_softirq+0x2de/0xa24 kernel/softirq.c:298
 run_ksoftirqd kernel/softirq.c:652 [inline]
 run_ksoftirqd+0x89/0x100 kernel/softirq.c:644
 smpboot_thread_fn+0x655/0x9e0 kernel/smpboot.c:165
 kthread+0x3b5/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Allocated by task 6854:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 kmalloc_node include/linux/slab.h:577 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:574
 kvmalloc include/linux/mm.h:750 [inline]
 kvzalloc include/linux/mm.h:758 [inline]
 xp_create_and_assign_umem+0x58/0x8d0 net/xdp/xsk_buff_pool.c:54
 xsk_bind+0x9a0/0xed0 net/xdp/xsk.c:709
 __sys_bind+0x1e9/0x250 net/socket.c:1656
 __do_sys_bind net/socket.c:1667 [inline]
 __se_sys_bind net/socket.c:1665 [inline]
 __x64_sys_bind+0x6f/0xb0 net/socket.c:1665
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 6854:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
 __cache_free mm/slab.c:3418 [inline]
 kfree+0x103/0x2c0 mm/slab.c:3756
 kvfree+0x42/0x50 mm/util.c:603
 xp_destroy net/xdp/xsk_buff_pool.c:44 [inline]
 xp_destroy+0x45/0x60 net/xdp/xsk_buff_pool.c:38
 xsk_bind+0xbdd/0xed0 net/xdp/xsk.c:719
 __sys_bind+0x1e9/0x250 net/socket.c:1656
 __do_sys_bind net/socket.c:1667 [inline]
 __se_sys_bind net/socket.c:1665 [inline]
 __x64_sys_bind+0x6f/0xb0 net/socket.c:1665
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8880a6a4d800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 96 bytes inside of
 1024-byte region [ffff8880a6a4d800, ffff8880a6a4dc00)
The buggy address belongs to the page:
page:00000000dd5fc18f refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xa6a4d
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00029cce48 ffffea00025f2148 ffff8880aa040700
raw: 0000000000000000 ffff8880a6a4d000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a6a4d700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a6a4d780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a6a4d800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8880a6a4d880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a6a4d900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (50):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/09/02 00:38 net-next-old dc1a9bf2c816 abf9ba4f .config console log report syz C ci-upstream-net-kasan-gce
2020/09/24 11:25 net-next-old 1a26e88d534b 54289b08 .config console log report info ci-upstream-net-kasan-gce
2020/09/23 15:32 net-next-old 748d1c8a425e 287cd75a .config console log report info ci-upstream-net-kasan-gce
2020/09/23 03:30 net-next-old 92ec804f3dbf 3e8f6c27 .config console log report info ci-upstream-net-kasan-gce
2020/09/22 13:18 net-next-old b696db590f5d 9e1fa68e .config console log report info ci-upstream-net-kasan-gce
2020/09/20 17:42 net-next-old dd92f1798981 9564d2e9 .config console log report info ci-upstream-net-kasan-gce
2020/09/19 06:39 net-next-old 1d39cd8cf75f 53ce8104 .config console log report info ci-upstream-net-kasan-gce
2020/09/13 01:48 net-next-old 5a6bd84f8154 ce441f06 .config console log report ci-upstream-net-kasan-gce
2020/09/11 05:14 net-next-old 4f6a5caf187f 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 23:02 net-next-old 4f6a5caf187f 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 22:46 net-next-old 4f6a5caf187f 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 18:14 net-next-old 4f6a5caf187f 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 17:21 net-next-old 4f6a5caf187f 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 12:44 net-next-old b599a5b9e166 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 12:40 net-next-old b599a5b9e166 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 08:24 net-next-old b599a5b9e166 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/10 05:33 net-next-old b599a5b9e166 409809d8 .config console log report ci-upstream-net-kasan-gce
2020/09/09 16:07 net-next-old f5499c67477e 0ea7a887 .config console log report ci-upstream-net-kasan-gce
2020/09/09 15:49 net-next-old f5499c67477e 0ea7a887 .config console log report ci-upstream-net-kasan-gce
2020/09/09 12:53 net-next-old f5499c67477e 0ea7a887 .config console log report ci-upstream-net-kasan-gce
2020/09/09 12:05 net-next-old f5499c67477e 0ea7a887 .config console log report ci-upstream-net-kasan-gce
2020/09/09 08:01 net-next-old c1f1f16c4de4 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/09 06:02 net-next-old c1f1f16c4de4 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 21:30 net-next-old 4349abdb409b abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 19:59 net-next-old 4349abdb409b abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 14:47 net-next-old 4349abdb409b abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 14:47 net-next-old 4349abdb409b abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 14:36 net-next-old 4349abdb409b abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 02:51 net-next-old bb1416adb8a0 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/08 01:28 net-next-old bb1416adb8a0 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/07 04:44 net-next-old 02a20d4fef3d abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/06 23:36 net-next-old be239c4d5e3e abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/06 18:05 net-next-old be239c4d5e3e abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/05 17:12 net-next-old 44a8c4f33c00 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/05 06:51 net-next-old 44a8c4f33c00 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/04 16:28 net-next-old 3ab1270bfa1e abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/04 04:53 net-next-old 22b330b622e3 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/03 23:54 net-next-old 22b330b622e3 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/03 23:40 net-next-old 22b330b622e3 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/03 19:05 net-next-old 22b330b622e3 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/03 12:56 net-next-old d3dfc362e073 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/02 20:36 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/02 10:32 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/02 01:20 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/01 23:46 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/01 23:43 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/01 23:39 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/01 23:24 net-next-old dc1a9bf2c816 abf9ba4f .config console log report ci-upstream-net-kasan-gce
2020/09/02 14:49 linux-next 4442749a2031 abf9ba4f .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.