KASAN: use-after-free Read in refcount_inc_not_zero

7 views
Skip to first unread message

syzbot

unread,
Apr 11, 2019, 7:45:15 PM4/11/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 1ec8f1f0 Linux 4.14.111
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16610dbb200000
kernel config: https://syzkaller.appspot.com/x/.config?x=fdadf290ea9fc6f9
dashboard link: https://syzkaller.appspot.com/bug?extid=9e1040586a4c03788599
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+9e1040...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:183
[inline]
BUG: KASAN: use-after-free in atomic_read arch/x86/include/asm/atomic.h:27
[inline]
BUG: KASAN: use-after-free in refcount_inc_not_zero+0xd3/0xe0
lib/refcount.c:120
Read of size 4 at addr ffff8880a88dd080 by task kworker/u4:4/2269

CPU: 0 PID: 2269 Comm: kworker/u4:4 Not tainted 4.14.111 #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: tipc_rcv tipc_recv_work
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x138/0x19c 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+0xaf/0x2b5 mm/kasan/report.c:393
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
__read_once_size include/linux/compiler.h:183 [inline]
atomic_read arch/x86/include/asm/atomic.h:27 [inline]
refcount_inc_not_zero+0xd3/0xe0 lib/refcount.c:120
refcount_inc+0x16/0x40 lib/refcount.c:153
kref_get include/linux/kref.h:47 [inline]
tipc_subscrb_get net/tipc/subscr.c:165 [inline]
tipc_subscrp_subscribe net/tipc/subscr.c:303 [inline]
tipc_subscrb_rcv_cb+0x61d/0xa80 net/tipc/subscr.c:338
tipc_receive_from_sock+0x28a/0x4e0 net/tipc/server.c:273
tipc_recv_work+0x8b/0xf0 net/tipc/server.c:547
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

Allocated by task 2817:
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
kmem_cache_alloc_trace+0x152/0x790 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
tipc_subscrb_create net/tipc/subscr.c:223 [inline]
tipc_subscrb_connect_cb+0x46/0x160 net/tipc/subscr.c:344
tipc_accept_from_sock+0x280/0x470 net/tipc/server.c:313
tipc_recv_work+0x8b/0xf0 net/tipc/server.c:547
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

Freed by task 2817:
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
tipc_subscrb_kref_release net/tipc/subscr.c:155 [inline]
kref_put include/linux/kref.h:70 [inline]
tipc_subscrb_put+0x27/0x30 net/tipc/subscr.c:160
tipc_subscrb_delete net/tipc/subscr.c:239 [inline]
tipc_subscrb_release_cb+0x20/0x30 net/tipc/subscr.c:316
tipc_close_conn+0x179/0x210 net/tipc/server.c:203
tipc_send_to_sock net/tipc/server.c:538 [inline]
tipc_send_work+0x470/0x5a0 net/tipc/server.c:564
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

The buggy address belongs to the object at ffff8880a88dd080
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
96-byte region [ffff8880a88dd080, ffff8880a88dd0e0)
The buggy address belongs to the page:
page:ffffea0002a23740 count:1 mapcount:0 mapping:ffff8880a88dd000 index:0x0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff8880a88dd000 0000000000000000 0000000100000020
raw: ffffea0002986560 ffffea000283cf20 ffff8880aa8004c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a88dcf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a88dd000: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> ffff8880a88dd080: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff8880a88dd100: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff8880a88dd180: fb fb fb fb fb fb fb fb fb fb fb fb 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,
Apr 24, 2019, 2:26:06 AM4/24/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: 68d7a45e Linux 4.14.113
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1112f7a0a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=dbf1fde4d7489e1c
dashboard link: https://syzkaller.appspot.com/bug?extid=9e1040586a4c03788599
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1423ced4a00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=119d195ca00000

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

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:186
[inline]
BUG: KASAN: use-after-free in atomic_read arch/x86/include/asm/atomic.h:27
[inline]
BUG: KASAN: use-after-free in refcount_inc_not_zero+0xd3/0xe0
lib/refcount.c:120
Read of size 4 at addr ffff8880979c1a80 by task kworker/u4:1/22

CPU: 1 PID: 22 Comm: kworker/u4:1 Not tainted 4.14.113 #3
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: tipc_rcv tipc_recv_work
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x138/0x19c 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+0xaf/0x2b5 mm/kasan/report.c:393
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
__read_once_size include/linux/compiler.h:186 [inline]
atomic_read arch/x86/include/asm/atomic.h:27 [inline]
refcount_inc_not_zero+0xd3/0xe0 lib/refcount.c:120
refcount_inc+0x16/0x40 lib/refcount.c:153
kref_get include/linux/kref.h:47 [inline]
tipc_subscrb_get net/tipc/subscr.c:165 [inline]
tipc_subscrp_subscribe net/tipc/subscr.c:303 [inline]
tipc_subscrb_rcv_cb+0x61d/0xa80 net/tipc/subscr.c:338
tipc_receive_from_sock+0x28a/0x4e0 net/tipc/server.c:273
tipc_recv_work+0x8b/0xf0 net/tipc/server.c:547
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

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
kmem_cache_alloc_trace+0x152/0x790 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
tipc_subscrb_create net/tipc/subscr.c:223 [inline]
tipc_subscrb_connect_cb+0x46/0x160 net/tipc/subscr.c:344
tipc_accept_from_sock+0x280/0x470 net/tipc/server.c:313
tipc_recv_work+0x8b/0xf0 net/tipc/server.c:547
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

Freed 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_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xcc/0x270 mm/slab.c:3815
tipc_subscrb_kref_release net/tipc/subscr.c:155 [inline]
kref_put include/linux/kref.h:70 [inline]
tipc_subscrb_put+0x27/0x30 net/tipc/subscr.c:160
tipc_subscrb_delete net/tipc/subscr.c:239 [inline]
tipc_subscrb_release_cb+0x20/0x30 net/tipc/subscr.c:316
tipc_close_conn+0x179/0x210 net/tipc/server.c:203
tipc_send_to_sock net/tipc/server.c:538 [inline]
tipc_send_work+0x470/0x5a0 net/tipc/server.c:564
process_one_work+0x868/0x1610 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x31c/0x430 kernel/kthread.c:232
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:402

The buggy address belongs to the object at ffff8880979c1a80
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
96-byte region [ffff8880979c1a80, ffff8880979c1ae0)
The buggy address belongs to the page:
page:ffffea00025e7040 count:1 mapcount:0 mapping:ffff8880979c1000
index:0xffff8880979c1000
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff8880979c1000 ffff8880979c1000 0000000100000008
raw: ffffea00023e9be0 ffffea0002482ca0 ffff8880aa8004c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880979c1980: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff8880979c1a00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
> ffff8880979c1a80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff8880979c1b00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff8880979c1b80: 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