KASAN: use-after-free Read in ip_check_mc_rcu

17 views
Skip to first unread message

syzbot

unread,
Mar 25, 2021, 11:27:26 AM3/25/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 78fec161 Linux 4.19.183
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=142d34aad00000
kernel config: https://syzkaller.appspot.com/x/.config?x=8b2beec637df5f52
dashboard link: https://syzkaller.appspot.com/bug?extid=bb58b36578bed8494f6d

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

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

VFS: unable to find oldfs superblock on device loop2
==================================================================
BUG: KASAN: use-after-free in ip_check_mc_rcu+0x694/0x6a0 net/ipv4/igmp.c:2743
Read of size 8 at addr ffff8880b1512018 by task syz-executor.1/1925

CPU: 1 PID: 1925 Comm: syz-executor.1 Not tainted 4.19.183-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+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.0'.
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
ip_check_mc_rcu+0x694/0x6a0 net/ipv4/igmp.c:2743
__mkroute_output net/ipv4/route.c:2267 [inline]
ip_route_output_key_hash_rcu+0x24be/0x3060 net/ipv4/route.c:2547
ip_route_output_key_hash+0x1c6/0x320 net/ipv4/route.c:2375
__ip_route_output_key include/net/route.h:124 [inline]
ip_route_output_flow+0x23/0x150 net/ipv4/route.c:2632
udp_sendmsg+0x19ce/0x2550 net/ipv4/udp.c:1101
inet_sendmsg+0x132/0x5a0 net/ipv4/af_inet.c:798
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x3b3/0x8e0 net/socket.c:2115
__sys_sendmmsg+0x195/0x470 net/socket.c:2210
__do_sys_sendmmsg net/socket.c:2239 [inline]
__se_sys_sendmmsg net/socket.c:2236 [inline]
__x64_sys_sendmmsg+0x99/0x100 net/socket.c:2236
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x466459
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7b57957188 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000466459
RDX: 000000000800001d RSI: 0000000020007fc0 RDI: 0000000000000004
RBP: 00000000004bf9fb R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007fffd4a8a30f R14: 00007f7b57957300 R15: 0000000000022000

Allocated by task 1925:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
ip_mc_add1_src net/ipv4/igmp.c:1986 [inline]
ip_mc_add_src+0x757/0xd50 net/ipv4/igmp.c:2110
ip_mc_msfilter+0x8a0/0xb60 net/ipv4/igmp.c:2494
do_ip_setsockopt.constprop.0+0x3416/0x3ba0 net/ipv4/ip_sockglue.c:957
ip_setsockopt+0x44/0xf0 net/ipv4/ip_sockglue.c:1246
tcp_setsockopt+0x86/0xd0 net/ipv4/tcp.c:3108
__sys_setsockopt+0x14d/0x240 net/socket.c:1901
__do_sys_setsockopt net/socket.c:1912 [inline]
__se_sys_setsockopt net/socket.c:1909 [inline]
__x64_sys_setsockopt+0xba/0x150 net/socket.c:1909
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 1896:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
ip_mc_del1_src+0x654/0x7a0 net/ipv4/igmp.c:1899
ip_mc_del_src.isra.0+0x2d8/0x920 net/ipv4/igmp.c:1940
ip_mc_leave_src.isra.0+0x102/0x240 net/ipv4/igmp.c:2246
ip_mc_drop_socket+0x11a/0x260 net/ipv4/igmp.c:2700
inet_release+0x49/0x1e0 net/ipv4/af_inet.c:414
__sock_release+0xcd/0x2a0 net/socket.c:579
sock_close+0x15/0x20 net/socket.c:1140
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880b1512000
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 24 bytes inside of
64-byte region [ffff8880b1512000, ffff8880b1512040)
The buggy address belongs to the page:
page:ffffea0002c54480 count:1 mapcount:0 mapping:ffff88813bff0340 index:0xffff8880b1512b00
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002478608 ffffea0002669348 ffff88813bff0340
raw: ffff8880b1512b00 ffff8880b1512000 000000010000001e 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b1511f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880b1511f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880b1512000: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8880b1512080: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
ffff8880b1512100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.0'.


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Mar 30, 2021, 3:21:24 PM3/30/21
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2034d6f0 Linux 4.19.184
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1698ebaad00000
kernel config: https://syzkaller.appspot.com/x/.config?x=42af7daace4bc0cc
dashboard link: https://syzkaller.appspot.com/bug?extid=bb58b36578bed8494f6d
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11bb34ced00000

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

==================================================================
BUG: KASAN: use-after-free in ip_check_mc_rcu+0x63a/0x6a0 net/ipv4/igmp.c:2738
Read of size 8 at addr ffff88809d4a2d00 by task syz-executor.4/15323

CPU: 1 PID: 15323 Comm: syz-executor.4 Not tainted 4.19.184-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+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
ip_check_mc_rcu+0x63a/0x6a0 net/ipv4/igmp.c:2738
__mkroute_output net/ipv4/route.c:2267 [inline]
ip_route_output_key_hash_rcu+0x24be/0x3060 net/ipv4/route.c:2547
ip_route_output_key_hash+0x1c6/0x320 net/ipv4/route.c:2375
__ip_route_output_key include/net/route.h:124 [inline]
ip_route_output_flow+0x23/0x150 net/ipv4/route.c:2632
udp_sendmsg+0x19ce/0x2550 net/ipv4/udp.c:1101
inet_sendmsg+0x132/0x5a0 net/ipv4/af_inet.c:798
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x3b3/0x8e0 net/socket.c:2115
__sys_sendmmsg+0x195/0x470 net/socket.c:2210
__do_sys_sendmmsg net/socket.c:2239 [inline]
__se_sys_sendmmsg net/socket.c:2236 [inline]
__x64_sys_sendmmsg+0x99/0x100 net/socket.c:2236
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x466459
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6b8bb9e188 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 000000000056c158 RCX: 0000000000466459
RDX: 000000000800001d RSI: 0000000020007fc0 RDI: 0000000000000004
RBP: 00000000004bf9fb R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056c158
R13: 00007ffd8a85dcaf R14: 00007f6b8bb9e300 R15: 0000000000022000

Allocated by task 15322:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
ip_mc_add1_src net/ipv4/igmp.c:1986 [inline]
ip_mc_add_src+0x999/0xd50 net/ipv4/igmp.c:2110
ip_mc_source+0xa49/0x1030 net/ipv4/igmp.c:2431
do_ip_setsockopt.constprop.0+0x31d/0x3ba0 net/ipv4/ip_sockglue.c:996
ip_setsockopt+0x44/0xf0 net/ipv4/ip_sockglue.c:1246
tcp_setsockopt+0x86/0xd0 net/ipv4/tcp.c:3108
__sys_setsockopt+0x14d/0x240 net/socket.c:1901
__do_sys_setsockopt net/socket.c:1912 [inline]
__se_sys_setsockopt net/socket.c:1909 [inline]
__x64_sys_setsockopt+0xba/0x150 net/socket.c:1909
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 15304:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
ip_mc_del1_src+0x654/0x7a0 net/ipv4/igmp.c:1899
ip_mc_del_src.isra.0+0x2d8/0x920 net/ipv4/igmp.c:1940
ip_mc_leave_src.isra.0+0x102/0x240 net/ipv4/igmp.c:2246
ip_mc_drop_socket+0x11a/0x260 net/ipv4/igmp.c:2700
inet_release+0x49/0x1e0 net/ipv4/af_inet.c:414
__sock_release+0xcd/0x2a0 net/socket.c:579
sock_close+0x15/0x20 net/socket.c:1140
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809d4a2d00
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff88809d4a2d00, ffff88809d4a2d40)
The buggy address belongs to the page:
page:ffffea0002752880 count:1 mapcount:0 mapping:ffff88813bff0340 index:0xffff88809d4a2b00
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002a89088 ffffea0002753988 ffff88813bff0340
raw: ffff88809d4a2b00 ffff88809d4a2000 000000010000000f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809d4a2c00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff88809d4a2c80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88809d4a2d00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88809d4a2d80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff88809d4a2e00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
Sep 22, 2021, 5:48:12 PM9/22/21
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 4768973dffed4d0126854514335ed4fe87bec1ab
Author: Liu Jian <liuj...@huawei.com>
Date: Fri Jul 16 04:06:17 2021 +0000

igmp: Add ip_mc_list lock in ip_check_mc_rcu

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=142e07f3300000
start commit: 4938296e03bd Linux 4.19.198
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=9013c716691ad1fe
dashboard link: https://syzkaller.appspot.com/bug?extid=bb58b36578bed8494f6d
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14594382300000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: igmp: Add ip_mc_list lock in ip_check_mc_rcu

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages