KASAN: use-after-free Read in batadv_iv_ogm_queue_add

7 views
Skip to first unread message

syzbot

unread,
Oct 14, 2019, 1:58:08 PM10/14/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: e132c8d7 Linux 4.14.149
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1486d04b600000
kernel config: https://syzkaller.appspot.com/x/.config?x=65c18705ca007f2
dashboard link: https://syzkaller.appspot.com/bug?extid=e7bfe3c4b6b706caa062
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

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

batman_adv: batadv0: Interface deactivated: veth3
batman_adv: batadv0: Removing interface: veth3
batman_adv: batadv0: Interface deactivated: veth5
batman_adv: batadv0: Removing interface: veth5
==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:347 [inline]
BUG: KASAN: use-after-free in batadv_iv_ogm_aggregate_new
net/batman-adv/bat_iv_ogm.c:717 [inline]
BUG: KASAN: use-after-free in batadv_iv_ogm_queue_add+0x2c2/0xf80
net/batman-adv/bat_iv_ogm.c:813
Read of size 60 at addr ffff88808b3ad780 by task kworker/u4:4/2289

CPU: 1 PID: 2289 Comm: kworker/u4:4 Not tainted 4.14.149 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
protocol 88fb is buggy, dev hsr_slave_0
Call Trace:
protocol 88fb is buggy, dev hsr_slave_1
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x138/0x197 lib/dump_stack.c:53
print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report mm/kasan/report.c:409 [inline]
kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
check_memory_region_inline mm/kasan/kasan.c:260 [inline]
check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
memcpy+0x24/0x50 mm/kasan/kasan.c:302
memcpy include/linux/string.h:347 [inline]
batadv_iv_ogm_aggregate_new net/batman-adv/bat_iv_ogm.c:717 [inline]
batadv_iv_ogm_queue_add+0x2c2/0xf80 net/batman-adv/bat_iv_ogm.c:813
batadv_iv_ogm_schedule+0x9c5/0xd20 net/batman-adv/bat_iv_ogm.c:982
batadv_iv_send_outstanding_bat_ogm_packet+0x4a1/0x680
net/batman-adv/bat_iv_ogm.c:1809
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 2289:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc mm/kasan/kasan.c:551 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15d/0x7a0 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
batadv_tvlv_realloc_packet_buff net/batman-adv/tvlv.c:288 [inline]
batadv_tvlv_container_ogm_append+0x12b/0x480 net/batman-adv/tvlv.c:329
batadv_iv_ogm_schedule+0xafe/0xd20 net/batman-adv/bat_iv_ogm.c:945
batadv_iv_send_outstanding_bat_ogm_packet+0x4a1/0x680
net/batman-adv/bat_iv_ogm.c:1809
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Freed by task 15464:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xcc/0x270 mm/slab.c:3815
batadv_iv_ogm_iface_disable+0x39/0x80 net/batman-adv/bat_iv_ogm.c:393
batadv_hardif_disable_interface.cold+0x4df/0x70d
net/batman-adv/hard-interface.c:836
batadv_softif_destroy_netlink+0xa9/0x130
net/batman-adv/soft-interface.c:1134
default_device_exit_batch+0x22c/0x3d0 net/core/dev.c:8723
ops_exit_list.isra.0+0xfc/0x150 net/core/net_namespace.c:145
cleanup_net+0x3ba/0x880 net/core/net_namespace.c:484
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff88808b3ad780
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff88808b3ad780, ffff88808b3ad7c0)
The buggy address belongs to the page:
page:ffffea00022ceb40 count:1 mapcount:0 mapping:ffff88808b3ad000
index:0xffff88808b3ad300
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff88808b3ad000 ffff88808b3ad300 0000000100000018
raw: ffffea00025c8120 ffffea00029749e0 ffff8880aa800340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808b3ad680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88808b3ad700: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff88808b3ad780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88808b3ad800: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff88808b3ad880: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
==================================================================


---
This bug 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 syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Feb 21, 2020, 12:27:11 AM2/21/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: 98db2bf2 Linux 4.14.171
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=166cda7ee00000
kernel config: https://syzkaller.appspot.com/x/.config?x=365f8162d5a0794b
dashboard link: https://syzkaller.appspot.com/bug?extid=e7bfe3c4b6b706caa062
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11e54c81e00000

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

IPv6: ADDRCONF(NETDEV_CHANGE): batadv_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
batman_adv: batadv0: Interface deactivated: batadv_slave_0
batman_adv: batadv0: Removing interface: batadv_slave_0
==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:347 [inline]
BUG: KASAN: use-after-free in batadv_iv_ogm_aggregate_new net/batman-adv/bat_iv_ogm.c:717 [inline]
BUG: KASAN: use-after-free in batadv_iv_ogm_queue_add+0x2c2/0xe30 net/batman-adv/bat_iv_ogm.c:813
Read of size 96 at addr ffff8880a8015d00 by task kworker/u4:0/5

CPU: 0 PID: 5 Comm: kworker/u4:0 Not tainted 4.14.171-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x142/0x197 lib/dump_stack.c:58
print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report mm/kasan/report.c:409 [inline]
kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
check_memory_region_inline mm/kasan/kasan.c:260 [inline]
check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
memcpy+0x24/0x50 mm/kasan/kasan.c:302
memcpy include/linux/string.h:347 [inline]
batadv_iv_ogm_aggregate_new net/batman-adv/bat_iv_ogm.c:717 [inline]
batadv_iv_ogm_queue_add+0x2c2/0xe30 net/batman-adv/bat_iv_ogm.c:813
batadv_iv_ogm_schedule+0xa61/0xe20 net/batman-adv/bat_iv_ogm.c:982
batadv_iv_send_outstanding_bat_ogm_packet+0x4a1/0x680 net/batman-adv/bat_iv_ogm.c:1809
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 5:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc mm/kasan/kasan.c:551 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15d/0x7a0 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
batadv_tvlv_realloc_packet_buff net/batman-adv/tvlv.c:288 [inline]
batadv_tvlv_container_ogm_append+0x12b/0x480 net/batman-adv/tvlv.c:329
batadv_iv_ogm_schedule+0xba0/0xe20 net/batman-adv/bat_iv_ogm.c:945
batadv_iv_send_outstanding_bat_ogm_packet+0x4a1/0x680 net/batman-adv/bat_iv_ogm.c:1809
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Freed by task 125:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xcc/0x270 mm/slab.c:3815
batadv_iv_ogm_iface_disable+0x39/0x80 net/batman-adv/bat_iv_ogm.c:393
batadv_hardif_disable_interface.cold+0x605/0x840 net/batman-adv/hard-interface.c:836
batadv_softif_destroy_netlink+0xad/0x140 net/batman-adv/soft-interface.c:1134
default_device_exit_batch+0x22c/0x3d0 net/core/dev.c:8734
ops_exit_list.isra.0+0xfc/0x150 net/core/net_namespace.c:145
cleanup_net+0x3ba/0x870 net/core/net_namespace.c:484
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff8880a8015d00
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
96-byte region [ffff8880a8015d00, ffff8880a8015d60)
The buggy address belongs to the page:
page:ffffea0002a00540 count:1 mapcount:0 mapping:ffff8880a8015000 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a8015000 0000000000000000 0000000100000020
raw: ffffea00022f72e0 ffffea000234e5e0 ffff8880aa8004c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a8015c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a8015c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a8015d00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff8880a8015d80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff8880a8015e00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Reply all
Reply to author
Forward
0 new messages