syzbot


KASAN: use-after-free Read in devlink_health_reporter_destroy

Status: fixed on 2020/09/16 22:51
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+dd0040db0d77d52f98a5@syzkaller.appspotmail.com
Fix commit: 5d037b4d3df7 devlink: Fix use-after-free when destroying health reporters
First crash: 1614d, last: 1610d
Cause bisection: failed (error log, bisect log)
  
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in devlink_health_reporter_destroy 1 (2) 2020/07/14 09:36

Sample crash report:
netdevsim netdevsim3 netdevsim0 (unregistering): unset [1, 0] type 2 family 0 port 6081 - 0
==================================================================
BUG: KASAN: use-after-free in devlink_health_reporter_destroy+0x184/0x1d0 net/core/devlink.c:5476
Read of size 8 at addr ffff88808ca11c20 by task kworker/u4:1/21

CPU: 1 PID: 21 Comm: kworker/u4:1 Not tainted 5.8.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: netns cleanup_net
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/0x436 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 devlink_health_reporter_destroy+0x184/0x1d0 net/core/devlink.c:5476
 nsim_dev_health_exit+0x8b/0xe0 drivers/net/netdevsim/health.c:317
 nsim_dev_reload_destroy+0x132/0x1e0 drivers/net/netdevsim/dev.c:1134
 nsim_dev_reload_down+0x6e/0xd0 drivers/net/netdevsim/dev.c:712
 devlink_reload+0xc1/0x3a0 net/core/devlink.c:2952
 devlink_pernet_pre_exit+0xfb/0x190 net/core/devlink.c:9622
 ops_pre_exit_list net/core/net_namespace.c:176 [inline]
 cleanup_net+0x451/0xa00 net/core/net_namespace.c:591
 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x3b5/0x4a0 kernel/kthread.c:291
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

Allocated by task 6819:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
 kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 __devlink_health_reporter_create+0x91/0x2f0 net/core/devlink.c:5359
 devlink_health_reporter_create+0xa1/0x1d0 net/core/devlink.c:5431
 nsim_dev_health_init+0x95/0x3a0 drivers/net/netdevsim/health.c:279
 nsim_dev_probe+0xada/0xf80 drivers/net/netdevsim/dev.c:1086
 really_probe+0x282/0x8a0 drivers/base/dd.c:525
 driver_probe_device+0xfe/0x1d0 drivers/base/dd.c:701
 __device_attach_driver+0x1c2/0x220 drivers/base/dd.c:807
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
 __device_attach+0x28d/0x3f0 drivers/base/dd.c:873
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
 device_add+0xacf/0x1b00 drivers/base/core.c:2680
 nsim_bus_dev_new drivers/net/netdevsim/bus.c:336 [inline]
 new_device_store+0x374/0x5c0 drivers/net/netdevsim/bus.c:215
 bus_attr_store+0x72/0xa0 drivers/base/bus.c:122
 sysfs_kf_write+0x110/0x160 fs/sysfs/file.c:138
 kernfs_fop_write+0x268/0x490 fs/kernfs/file.c:315
 vfs_write+0x2b0/0x6b0 fs/read_write.c:576
 ksys_write+0x12d/0x250 fs/read_write.c:631
 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 21:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x103/0x2c0 mm/slab.c:3757
 devlink_health_reporter_free net/core/devlink.c:5449 [inline]
 devlink_health_reporter_put+0xb7/0xf0 net/core/devlink.c:5456
 __devlink_health_reporter_destroy net/core/devlink.c:5463 [inline]
 devlink_health_reporter_destroy+0x143/0x1d0 net/core/devlink.c:5475
 nsim_dev_health_exit+0x8b/0xe0 drivers/net/netdevsim/health.c:317
 nsim_dev_reload_destroy+0x132/0x1e0 drivers/net/netdevsim/dev.c:1134
 nsim_dev_reload_down+0x6e/0xd0 drivers/net/netdevsim/dev.c:712
 devlink_reload+0xc1/0x3a0 net/core/devlink.c:2952
 devlink_pernet_pre_exit+0xfb/0x190 net/core/devlink.c:9622
 ops_pre_exit_list net/core/net_namespace.c:176 [inline]
 cleanup_net+0x451/0xa00 net/core/net_namespace.c:591
 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x3b5/0x4a0 kernel/kthread.c:291
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

The buggy address belongs to the object at ffff88808ca11c00
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 32 bytes inside of
 512-byte region [ffff88808ca11c00, ffff88808ca11e00)
The buggy address belongs to the page:
page:ffffea0002328440 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88808ca11000
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00024ba648 ffffea0002a32788 ffff8880aa000a80
raw: ffff88808ca11000 ffff88808ca11000 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808ca11b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88808ca11b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88808ca11c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88808ca11c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808ca11d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1188):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/07/12 20:49 net-next-old 71930d61025e 115e1930 .config console log report syz C ci-upstream-net-kasan-gce
2020/07/11 00:03 net-next-old a594920f8747 18d18b59 .config console log report syz C ci-upstream-net-kasan-gce
2020/07/14 13:30 linux-next be978f8feb1d ce4c95b3 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/07/14 01:56 linux-next be978f8feb1d f90ec899 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/07/11 17:16 net-next-old a594920f8747 18d18b59 .config console log report syz ci-upstream-net-kasan-gce
2020/07/14 16:18 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 15:18 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 14:16 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 12:52 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 11:42 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 10:36 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 09:38 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 09:11 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 08:03 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 08:03 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 07:00 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 06:50 net-next-old 2be53e0e4690 ce4c95b3 .config console log report ci-upstream-net-kasan-gce
2020/07/14 03:37 net-next-old 2be53e0e4690 f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/14 01:03 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 23:26 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 21:51 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 21:35 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 20:31 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 18:43 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 17:37 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 16:36 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 15:32 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 15:17 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 14:10 net-next-old 94339443686b f90ec899 .config console log report ci-upstream-net-kasan-gce
2020/07/13 10:07 net-next-old 94339443686b 9ebcc5b1 .config console log report ci-upstream-net-kasan-gce
2020/07/13 09:07 net-next-old 94339443686b 9ebcc5b1 .config console log report ci-upstream-net-kasan-gce
2020/07/10 22:28 net-next-old a594920f8747 18d18b59 .config console log report ci-upstream-net-kasan-gce
2020/07/14 17:41 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 17:19 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 15:38 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 12:47 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 05:46 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 04:46 linux-next be978f8feb1d ce4c95b3 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 04:06 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 02:36 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/14 00:31 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 22:52 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 20:10 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 19:04 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 12:34 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 11:35 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 11:00 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/07/13 10:36 linux-next be978f8feb1d f90ec899 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.