KASAN: use-after-free Read in tipc_group_self

12 views
Skip to first unread message

syzbot

unread,
Oct 24, 2017, 11:14:02 AM10/24/17
to da...@davemloft.net, jon....@ericsson.com, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, tipc-di...@lists.sourceforge.net, ying...@windriver.com
Hello,

syzkaller hit the following crash on
65302eba00aea2f1bc715f0438afb63470ac138b
git://git.cmpxchg.org/linux-mmots.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
C reproducer is attached
syzkaller reproducer is attached. See https://goo.gl/kgGztJ
for information about syzkaller reproducers


BUG: KASAN: use-after-free in tipc_group_self+0x1a2/0x1b0
net/tipc/group.c:335
Read of size 4 at addr ffff8801d805726c by task syzkaller195348/2990

CPU: 0 PID: 2990 Comm: syzkaller195348 Not tainted 4.14.0-rc5-mm1+ #19
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:16 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:52
print_address_description+0x73/0x250 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x25b/0x340 mm/kasan/report.c:409
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
tipc_group_self+0x1a2/0x1b0 net/tipc/group.c:335
tipc_sk_leave+0xfc/0x200 net/tipc/socket.c:2781
tipc_release+0x154/0xfe0 net/tipc/socket.c:575
sock_release+0x8d/0x1e0 net/socket.c:596
sock_close+0x16/0x20 net/socket.c:1125
__fput+0x327/0x7e0 fs/file_table.c:210
____fput+0x15/0x20 fs/file_table.c:244
task_work_run+0x199/0x270 kernel/task_work.c:112
exit_task_work include/linux/task_work.h:21 [inline]
do_exit+0x9b5/0x1ad0 kernel/exit.c:869
do_group_exit+0x149/0x400 kernel/exit.c:972
SYSC_exit_group kernel/exit.c:983 [inline]
SyS_exit_group+0x1d/0x20 kernel/exit.c:981
entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x43e978
RSP: 002b:00007ffcae951f88 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043e978
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 0000000000000082 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 000000002010e000 R11: 0000000000000246 R12: 00000000006ca858
R13: 00000000006ca858 R14: 0000000000000000 R15: 0000000000002710

Allocated by task 2990:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x136/0x750 mm/slab.c:3614
kmalloc include/linux/slab.h:499 [inline]
kzalloc include/linux/slab.h:688 [inline]
tipc_group_create+0x116/0x9c0 net/tipc/group.c:167
tipc_sk_join net/tipc/socket.c:2751 [inline]
tipc_setsockopt+0x25e/0xc00 net/tipc/socket.c:2863
SYSC_setsockopt net/socket.c:1851 [inline]
SyS_setsockopt+0x189/0x360 net/socket.c:1830
entry_SYSCALL_64_fastpath+0x1f/0xbe

Freed by task 2990:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3492 [inline]
kfree+0xca/0x250 mm/slab.c:3807
tipc_group_delete+0x2c0/0x3c0 net/tipc/group.c:206
tipc_sk_join net/tipc/socket.c:2764 [inline]
tipc_setsockopt+0xb33/0xc00 net/tipc/socket.c:2863
SYSC_setsockopt net/socket.c:1851 [inline]
SyS_setsockopt+0x189/0x360 net/socket.c:1830
entry_SYSCALL_64_fastpath+0x1f/0xbe

The buggy address belongs to the object at ffff8801d8057200
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 108 bytes inside of
192-byte region [ffff8801d8057200, ffff8801d80572c0)
The buggy address belongs to the page:
page:ffffea00076015c0 count:1 mapcount:0 mapping:ffff8801d8057000
index:0xffff8801d8057400
flags: 0x200000000000100(slab)
raw: 0200000000000100 ffff8801d8057000 ffff8801d8057400 000000010000000f
raw: ffffea00075912e0 ffff8801dac01138 ffff8801dac00040 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d8057100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d8057180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff8801d8057200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d8057280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8801d8057300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzk...@googlegroups.com.

syzbot will keep track of this bug report.
Once a fix for this bug is committed, please reply to this email with:
#syz fix: exact-commit-title
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
config.txt
raw.log
repro.txt
repro.c

Cong Wang

unread,
Oct 24, 2017, 4:31:05 PM10/24/17
to syzbot, David Miller, jon....@ericsson.com, LKML, Linux Kernel Network Developers, syzkall...@googlegroups.com, tipc-di...@lists.sourceforge.net, ying...@windriver.com
On Tue, Oct 24, 2017 at 8:14 AM, syzbot
<bot+dbf0bb71d5568dfcd9...@syzkaller.appspotmail.com>
wrote:
Should be fixed by:

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index b3b72d8e9543..ea61c32f6b80 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2756,8 +2756,10 @@ static int tipc_sk_join(struct tipc_sock *tsk,
struct tipc_group_req *mreq)
seq.upper = seq.lower;
tipc_nametbl_build_group(net, grp, mreq->type, domain);
rc = tipc_sk_publish(tsk, mreq->scope, &seq);
- if (rc)
+ if (rc) {
tipc_group_delete(net, grp);
+ tsk->group = NULL;
+ }

/* Eliminate any risk that a broadcast overtakes the sent JOIN */
tsk->mc_method.rcast = true;

Cong Wang

unread,
Oct 26, 2017, 2:29:50 PM10/26/17
to syzbot, David Miller, Jon Maloy, LKML, Linux Kernel Network Developers, syzkall...@googlegroups.com, tipc-di...@lists.sourceforge.net, Ying Xue
#syz fix: tipc: fix a dangling pointer
Reply all
Reply to author
Forward
0 new messages