KASAN: slab-out-of-bounds Read in u32_mt

Status: upstream: reported C repro on 2020/02/03 17:49
First crash: 1597d, last: 1417d
Fix bisection the fix commit could be any of (bisect log):
  9fa690a2a016 Linux 4.14.169
  56dfe6252c68 Linux 4.14.188
Last patch testing requests (4)
Created Duration User Patch Repo Result
2023/01/29 01:32 10m retest repro linux-4.14.y report log
2023/01/29 00:32 10m retest repro linux-4.14.y report log
2022/09/09 19:27 9m retest repro linux-4.14.y report log
2022/09/09 18:27 9m retest repro linux-4.14.y report log
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2020/07/17 22:29 33m bisect fix linux-4.14.y job log (2)
2020/06/17 22:04 24m bisect fix linux-4.14.y job log (0) log
2020/05/03 18:39 28m bisect fix linux-4.14.y job log (0) log
2020/04/03 18:13 25m bisect fix linux-4.14.y job log (0) log
2020/03/04 17:48 25m bisect fix linux-4.14.y job log (0) log

Sample crash report:
audit: type=1400 audit(1596296553.812:8): avc:  denied  { execmem } for  pid=6354 comm="syz-executor676" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
ip_tables: iptables: counters copy to user failed while replacing table
BUG: KASAN: slab-out-of-bounds in u32_match_it net/netfilter/xt_u32.c:49 [inline]
BUG: KASAN: slab-out-of-bounds in u32_mt+0x508/0x5b0 net/netfilter/xt_u32.c:94
Read of size 1 at addr ffff8880976a7770 by task sshd/6348

CPU: 1 PID: 6348 Comm: sshd Not tainted 4.14.191-syzkaller #0
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+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load1_noabort+0x68/0x70 mm/kasan/report.c:427
 u32_match_it net/netfilter/xt_u32.c:49 [inline]
 u32_mt+0x508/0x5b0 net/netfilter/xt_u32.c:94
 ipt_do_table+0x87b/0x16f0 net/ipv4/netfilter/ip_tables.c:301
 iptable_filter_hook+0x172/0x1e0 net/ipv4/netfilter/iptable_filter.c:47
 nf_hook_entry_hookfn include/linux/netfilter.h:108 [inline]
 nf_hook_slow+0xb0/0x1a0 net/netfilter/core.c:467
 nf_hook include/linux/netfilter.h:205 [inline]
 __ip_local_out+0x398/0x730 net/ipv4/ip_output.c:113
 ip_local_out+0x25/0x170 net/ipv4/ip_output.c:122
 ip_queue_xmit+0x7d3/0x1a80 net/ipv4/ip_output.c:504
 __tcp_transmit_skb+0x17e2/0x2cb0 net/ipv4/tcp_output.c:1133
 tcp_transmit_skb net/ipv4/tcp_output.c:1149 [inline]
 tcp_write_xmit+0x69d/0x4e10 net/ipv4/tcp_output.c:2393
 __tcp_push_pending_frames+0xa0/0x230 net/ipv4/tcp_output.c:2577
 tcp_push+0x3fd/0x5f0 net/ipv4/tcp.c:715
 tcp_sendmsg_locked+0x2153/0x2ef0 net/ipv4/tcp.c:1426
 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1457
 inet_sendmsg+0x11a/0x4e0 net/ipv4/af_inet.c:762
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xb5/0x100 net/socket.c:656
 sock_write_iter+0x22c/0x370 net/socket.c:925
 call_write_iter include/linux/fs.h:1778 [inline]
 new_sync_write fs/read_write.c:469 [inline]
 __vfs_write+0x44c/0x630 fs/read_write.c:482
 vfs_write+0x17f/0x4d0 fs/read_write.c:544
 SYSC_write fs/read_write.c:590 [inline]
 SyS_write+0xf2/0x210 fs/read_write.c:582
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
RIP: 0033:0x7f172f0b8970
RSP: 002b:00007ffebc77ae48 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 000000000000007c RCX: 00007f172f0b8970
RDX: 000000000000007c RSI: 000055f3841ff42c RDI: 0000000000000003
RBP: 000055f3841f06e0 R08: 00007ffebc77abf0 R09: 0000000000267792
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffebc77aedf R14: 000055f382d6cbe7 R15: 0000000000000003

Allocated by task 6355:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 __do_kmalloc_node mm/slab.c:3682 [inline]
 __kmalloc_node+0x4c/0x70 mm/slab.c:3689
 kmalloc_node include/linux/slab.h:530 [inline]
 kvmalloc_node+0x46/0xd0 mm/util.c:397
 kvmalloc include/linux/mm.h:531 [inline]
 xt_alloc_table_info+0x6a/0xe0 net/netfilter/x_tables.c:1062
 do_replace net/ipv4/netfilter/ip_tables.c:1127 [inline]
 do_ipt_set_ctl+0x1b1/0x39e net/ipv4/netfilter/ip_tables.c:1674
 nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
 nf_setsockopt+0x5f/0xb0 net/netfilter/nf_sockopt.c:115
 ip_setsockopt net/ipv4/ip_sockglue.c:1255 [inline]
 ip_setsockopt+0x94/0xb0 net/ipv4/ip_sockglue.c:1240
 udp_setsockopt+0x45/0x80 net/ipv4/udp.c:2451
 SYSC_setsockopt net/socket.c:1865 [inline]
 SyS_setsockopt+0x110/0x1e0 net/socket.c:1844
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff8880976a6cc0
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 2736 bytes inside of
 4096-byte region [ffff8880976a6cc0, ffff8880976a7cc0)
The buggy address belongs to the page:
page:ffffea00025da980 count:1 mapcount:0 mapping:ffff8880976a6cc0 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff8880976a6cc0 0000000000000000 0000000100000001
raw: ffffea000261af20 ffff88812fe50a48 ffff88812fe52dc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880976a7600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880976a7680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880976a7700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
 ffff8880976a7780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880976a7800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/08/01 15:44 linux-4.14.y 7f2c5eb458b8 8df85ed9 .config console log report syz C ci2-linux-4-14
2020/02/03 17:48 linux-4.14.y 9fa690a2a016 93e5e335 .config console log report syz C ci2-linux-4-14
2020/05/18 22:04 linux-4.14.y ab9dfda23248 24d91142 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.