syzbot


KASAN: stack-out-of-bounds Write in compat_copy_entries

Status: fixed on 2018/06/07 13:52
Subsystems: bridge netfilter
[Documentation on labels]
Reported-by: syzbot+4e42a04e0bc33cb6c087@syzkaller.appspotmail.com
Fix commit: 94c752f99954 netfilter: ebtables: handle string from userspace with care
First crash: 2193d, last: 2155d
Discussions (8)
Title Replies (including bot) Last reply
[PATCH 3.16 000/366] 3.16.60-rc1 review 370 (370) 2019/03/29 15:47
[PATCH 4.4 000/105] 4.4.139-stable review 106 (106) 2018/07/26 15:09
[PATCH 3.18 00/23] 3.18.115-stable review 29 (29) 2018/07/11 15:10
[PATCH 4.14 00/61] 4.14.54-stable review 57 (58) 2018/07/09 13:28
[PATCH 4.9 00/39] 4.9.110-stable review 39 (39) 2018/06/25 17:18
[PATCH 0/9] Netfilter/IPVS fixes for net 11 (11) 2018/05/29 02:39
[PATCH] netfilter: ebtables: handle string from userspace with care 4 (4) 2018/05/18 07:51
KASAN: stack-out-of-bounds Write in compat_copy_entries 0 (1) 2018/04/25 05:19

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
IPv6: ADDRCONF(NETDEV_UP): team0: link is not ready
8021q: adding VLAN 0 to HW filter on device team0
IPv6: ADDRCONF(NETDEV_CHANGE): team0: link becomes ready
==================================================================
BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300 [inline]
BUG: KASAN: stack-out-of-bounds in compat_mtw_from_user net/bridge/netfilter/ebtables.c:1957 [inline]
BUG: KASAN: stack-out-of-bounds in ebt_size_mwt net/bridge/netfilter/ebtables.c:2059 [inline]
BUG: KASAN: stack-out-of-bounds in size_entry_mwt net/bridge/netfilter/ebtables.c:2155 [inline]
BUG: KASAN: stack-out-of-bounds in compat_copy_entries+0x96c/0x14a0 net/bridge/netfilter/ebtables.c:2194
Write of size 33 at addr ffff8801d960f888 by task syz-executor0/4737

CPU: 1 PID: 4737 Comm: syz-executor0 Not tainted 4.17.0-rc7+ #103
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+0x1b9/0x294 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 memcpy+0x37/0x50 mm/kasan/kasan.c:303
 strlcpy include/linux/string.h:300 [inline]
 compat_mtw_from_user net/bridge/netfilter/ebtables.c:1957 [inline]
 ebt_size_mwt net/bridge/netfilter/ebtables.c:2059 [inline]
 size_entry_mwt net/bridge/netfilter/ebtables.c:2155 [inline]
 compat_copy_entries+0x96c/0x14a0 net/bridge/netfilter/ebtables.c:2194
 compat_do_replace+0x483/0x900 net/bridge/netfilter/ebtables.c:2285
 compat_do_ebt_set_ctl+0x2ac/0x324 net/bridge/netfilter/ebtables.c:2367
 compat_nf_sockopt net/netfilter/nf_sockopt.c:144 [inline]
 compat_nf_setsockopt+0x9b/0x140 net/netfilter/nf_sockopt.c:156
 compat_ip_setsockopt+0xff/0x140 net/ipv4/ip_sockglue.c:1277
 inet_csk_compat_setsockopt+0x97/0x120 net/ipv4/inet_connection_sock.c:1041
 compat_tcp_setsockopt+0x49/0x80 net/ipv4/tcp.c:2902
 compat_sock_common_setsockopt+0xb4/0x150 net/core/sock.c:3050
 __compat_sys_setsockopt+0x1ab/0x840 net/compat.c:404
 __do_compat_sys_setsockopt net/compat.c:417 [inline]
 __se_compat_sys_setsockopt net/compat.c:414 [inline]
 __ia32_compat_sys_setsockopt+0xbd/0x150 net/compat.c:414
 do_syscall_32_irqs_on arch/x86/entry/common.c:323 [inline]
 do_fast_syscall_32+0x345/0xf9b arch/x86/entry/common.c:394
 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
RIP: 0023:0xf7f3acb9
RSP: 002b:00000000ffb028cc EFLAGS: 00000282 ORIG_RAX: 000000000000016e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000000
RDX: 0000000000000080 RSI: 0000000020000040 RDI: 0000000000000554
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

The buggy address belongs to the page:
page:ffffea00076583c0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x2fffc0000000000()
raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffffff
raw: 0000000000000000 ffffea0007650101 0000000000000000 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d960f780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801d960f800: 00 00 00 00 00 f1 f1 f1 f1 00 00 f2 f2 f2 f2 f2
>ffff8801d960f880: f2 00 00 00 07 f3 f3 f3 f3 00 00 00 00 00 00 00
                               ^
 ffff8801d960f900: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00
 ffff8801d960f980: 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/06/02 12:04 upstream 0512e0134582 2f93b54f .config console log report syz ci-upstream-kasan-gce-386
2018/05/30 07:44 upstream 0044cdeb7313 2f93b54f .config console log report syz ci-upstream-kasan-gce-386
2018/05/20 04:11 upstream 0b449a441dac f48c20b8 .config console log report syz ci-upstream-kasan-gce-386
2018/04/25 05:27 upstream 24cac7009cb1 37e76fe2 .config console log report syz ci-upstream-kasan-gce-386
2018/04/25 05:10 upstream 24cac7009cb1 37e76fe2 .config console log report syz ci-upstream-kasan-gce-386
2018/06/02 11:42 upstream 0512e0134582 2f93b54f .config console log report ci-upstream-kasan-gce-386
2018/05/30 07:30 upstream 0044cdeb7313 2f93b54f .config console log report ci-upstream-kasan-gce-386
2018/05/20 03:51 upstream 0b449a441dac f48c20b8 .config console log report ci-upstream-kasan-gce-386
2018/04/24 23:54 upstream 24cac7009cb1 37e76fe2 .config console log report ci-upstream-kasan-gce-386
2018/04/24 22:51 upstream 24cac7009cb1 37e76fe2 .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.