syzbot


KASAN: use-after-free Write in xt_rateest_tg_checkentry

Status: fixed on 2018/02/12 17:26
Subsystems: netfilter
[Documentation on labels]
Reported-by: syzbot+5cb189720978275e4c75@syzkaller.appspotmail.com
Fix commit: 7dc68e98757a netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert
First crash: 2279d, last: 2278d
Discussions (11)
Title Replies (including bot) Last reply
[PATCH 3.16 000/410] 3.16.57-rc1 review 426 (426) 2018/11/12 17:42
[PATCH 3.2 000/153] 3.2.102-rc1 review 155 (155) 2018/05/30 22:14
[PATCH 4.9 000/145] 4.9.84-stable review 153 (153) 2018/04/06 15:55
[PATCH 4.4 000/193] 4.4.118-stable review 227 (227) 2018/03/13 10:51
[PATCH 4.15 00/45] 4.15.6-stable review 53 (53) 2018/02/25 09:59
[PATCH 3.18 00/58] 3.18.96-stable review 64 (64) 2018/02/24 18:38
[PATCH 4.14 000/159] 4.14.22-stable review 164 (164) 2018/02/24 17:57
[PATCH 00/11] Netfilter fixes for net 13 (13) 2018/02/07 18:56
[Patch net v2] xt_RATEEST: acquire xt_rateest_mutex for hash insert 4 (4) 2018/02/06 12:26
[Patch net] xt_RATEEST: acquire xt_rateest_mutex for hash insert 4 (4) 2018/02/01 22:36
KASAN: use-after-free Write in xt_rateest_tg_checkentry 0 (1) 2018/01/29 14:58

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:674 [inline]
BUG: KASAN: use-after-free in xt_rateest_hash_insert net/netfilter/xt_RATEEST.c:39 [inline]
BUG: KASAN: use-after-free in xt_rateest_tg_checkentry+0xa01/0xaa0 net/netfilter/xt_RATEEST.c:141
Write of size 8 at addr ffff8801acb27358 by task syzkaller682628/4166

CPU: 0 PID: 4166 Comm: syzkaller682628 Not tainted 4.15.0-rc9+ #217
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 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_store8_noabort+0x17/0x20 mm/kasan/report.c:435
 hlist_add_head include/linux/list.h:674 [inline]
 xt_rateest_hash_insert net/netfilter/xt_RATEEST.c:39 [inline]
 xt_rateest_tg_checkentry+0xa01/0xaa0 net/netfilter/xt_RATEEST.c:141
 xt_check_target+0x22c/0x7d0 net/netfilter/x_tables.c:845
 check_target net/ipv6/netfilter/ip6_tables.c:538 [inline]
 find_check_entry.isra.7+0x935/0xcf0 net/ipv6/netfilter/ip6_tables.c:580
 translate_table+0xf52/0x1690 net/ipv6/netfilter/ip6_tables.c:749
 do_replace net/ipv6/netfilter/ip6_tables.c:1165 [inline]
 do_ip6t_set_ctl+0x370/0x5f0 net/ipv6/netfilter/ip6_tables.c:1691
 nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
 nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
 ipv6_setsockopt+0x115/0x150 net/ipv6/ipv6_sockglue.c:928
 udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
 sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
 SYSC_setsockopt net/socket.c:1849 [inline]
 SyS_setsockopt+0x189/0x360 net/socket.c:1828
 entry_SYSCALL_64_fastpath+0x29/0xa0
RIP: 0033:0x4412d9
RSP: 002b:00007ffdef6232a8 EFLAGS: 00000203 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: ffffffffffffffff RCX: 00000000004412d9
RDX: 0000000000000040 RSI: 0000000000000029 RDI: 00000000000002fe
RBP: f6fcce9cd855ec40 R08: 00000000000003b8 R09: 0000000000000000
R10: 0000000020019c48 R11: 0000000000000203 R12: fbfe5b6031634428
R13: 5826b2d59f7fe9a1 R14: fd7217c033abf8b5 R15: 0000000000000000

Allocated by task 4164:
 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:3610
 kmalloc include/linux/slab.h:499 [inline]
 kzalloc include/linux/slab.h:688 [inline]
 xt_rateest_tg_checkentry+0x25a/0xaa0 net/netfilter/xt_RATEEST.c:120
 xt_check_target+0x22c/0x7d0 net/netfilter/x_tables.c:845
 check_target net/ipv6/netfilter/ip6_tables.c:538 [inline]
 find_check_entry.isra.7+0x935/0xcf0 net/ipv6/netfilter/ip6_tables.c:580
 translate_table+0xf52/0x1690 net/ipv6/netfilter/ip6_tables.c:749
 do_replace net/ipv6/netfilter/ip6_tables.c:1165 [inline]
 do_ip6t_set_ctl+0x370/0x5f0 net/ipv6/netfilter/ip6_tables.c:1691
 nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
 nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
 ipv6_setsockopt+0x115/0x150 net/ipv6/ipv6_sockglue.c:928
 udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
 sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
 SYSC_setsockopt net/socket.c:1849 [inline]
 SyS_setsockopt+0x189/0x360 net/socket.c:1828
 entry_SYSCALL_64_fastpath+0x29/0xa0

Freed by task 4166:
 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:3488 [inline]
 kfree+0xd6/0x260 mm/slab.c:3803
 __rcu_reclaim kernel/rcu/rcu.h:190 [inline]
 rcu_do_batch kernel/rcu/tree.c:2758 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:3012 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2979 [inline]
 rcu_process_callbacks+0xe94/0x17f0 kernel/rcu/tree.c:2996
 __do_softirq+0x2d7/0xb85 kernel/softirq.c:285

The buggy address belongs to the object at ffff8801acb27300
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 88 bytes inside of
 192-byte region [ffff8801acb27300, ffff8801acb273c0)
The buggy address belongs to the page:
page:ffffea0006b2c9c0 count:1 mapcount:0 mapping:ffff8801acb27000 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801acb27000 0000000000000000 0000000100000010
raw: ffffea0006b2cc60 ffffea0006b2ce20 ffff8801db000040 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801acb27200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801acb27280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8801acb27300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8801acb27380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8801acb27400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/01/30 20:43 net-next-old 91e6dd828425 a899be78 .config console log report syz C ci-upstream-net-kasan-gce
2018/01/29 10:41 net-next-old 868c36dcc949 08d47756 .config console log report syz C ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.