syzbot


KASAN: use-after-free Read in nf_ct_deliver_cached_events

Status: fixed on 2019/12/13 00:31
Subsystems: netfilter
[Documentation on labels]
Reported-by: syzbot+c7aabc9fe93e7f3637ba@syzkaller.appspotmail.com
Fix commit: ad88b7a6aa3e netfilter: ecache: don't look for ecache extension on dying/unconfirmed conntracks
First crash: 1700d, last: 1693d
Cause bisection: introduced by (bisect log) :
commit 2341e0775747864b684abe8627f3d45b167f2940
Author: David Howells <dhowells@redhat.com>
Date: Thu Jun 9 22:02:51 2016 +0000

  rxrpc: Simplify connect() implementation and simplify sendmsg() op

Crash: kernel BUG at net/rxrpc/af_rxrpc.c:LINE! (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
[PATCH 00/31] Netfilter/IPVS updates for net-next 33 (33) 2019/10/26 18:36
[PATCH nf-next] netfilter: ecache: don't look for ecache extension on dying/unconfirmed conntracks 3 (3) 2019/10/26 18:27
KASAN: use-after-free Read in nf_ct_deliver_cached_events 1 (4) 2019/10/25 06:11

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __nf_ct_ext_exist include/net/netfilter/nf_conntrack_extend.h:53 [inline]
BUG: KASAN: use-after-free in nf_ct_ext_exist include/net/netfilter/nf_conntrack_extend.h:58 [inline]
BUG: KASAN: use-after-free in __nf_ct_ext_find include/net/netfilter/nf_conntrack_extend.h:63 [inline]
BUG: KASAN: use-after-free in nf_ct_ecache_find include/net/netfilter/nf_conntrack_ecache.h:35 [inline]
BUG: KASAN: use-after-free in nf_ct_deliver_cached_events+0x5c3/0x6d0 net/netfilter/nf_conntrack_ecache.c:205
Read of size 1 at addr ffff88809bad1004 by task syz-executor403/9183

CPU: 1 PID: 9183 Comm: syz-executor403 Not tainted 5.4.0-rc4-next-20191025 #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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:634
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/generic_report.c:129
 __nf_ct_ext_exist include/net/netfilter/nf_conntrack_extend.h:53 [inline]
 nf_ct_ext_exist include/net/netfilter/nf_conntrack_extend.h:58 [inline]
 __nf_ct_ext_find include/net/netfilter/nf_conntrack_extend.h:63 [inline]
 nf_ct_ecache_find include/net/netfilter/nf_conntrack_ecache.h:35 [inline]
 nf_ct_deliver_cached_events+0x5c3/0x6d0 net/netfilter/nf_conntrack_ecache.c:205
 nf_conntrack_confirm include/net/netfilter/nf_conntrack_core.h:65 [inline]
 nf_confirm+0x3d8/0x4d0 net/netfilter/nf_conntrack_proto.c:154
 ipv4_confirm+0x14c/0x240 net/netfilter/nf_conntrack_proto.c:169
 nf_hook_entry_hookfn include/linux/netfilter.h:135 [inline]
 nf_hook_slow+0xbc/0x1e0 net/netfilter/core.c:512
 nf_hook include/linux/netfilter.h:262 [inline]
 NF_HOOK_COND include/linux/netfilter.h:295 [inline]
 ip_output+0x40d/0x670 net/ipv4/ip_output.c:432
 dst_output include/net/dst.h:436 [inline]
 ip_local_out+0xbb/0x1b0 net/ipv4/ip_output.c:125
 ip_send_skb+0x42/0xf0 net/ipv4/ip_output.c:1559
 udp_send_skb.isra.0+0x6d5/0x11b0 net/ipv4/udp.c:891
 udp_sendmsg+0x1e8f/0x2810 net/ipv4/udp.c:1178
 inet_sendmsg+0x9e/0xe0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 kernel_sendmsg+0x44/0x50 net/socket.c:678
 rxrpc_send_data_packet+0x10cb/0x36b0 net/rxrpc/output.c:416
 rxrpc_queue_packet net/rxrpc/sendmsg.c:220 [inline]
 rxrpc_send_data+0x1097/0x4130 net/rxrpc/sendmsg.c:427
 rxrpc_do_sendmsg+0xb8e/0x1d5f net/rxrpc/sendmsg.c:736
 rxrpc_sendmsg+0x4d6/0x5f0 net/rxrpc/af_rxrpc.c:585
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2312
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2414
 __do_sys_sendmmsg net/socket.c:2443 [inline]
 __se_sys_sendmmsg net/socket.c:2440 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2440
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x441249
Code: e8 fc ab 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 9b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc583ed468 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441249
RDX: 0000000000000001 RSI: 0000000020005c00 RDI: 0000000000000003
RBP: 0000000000010f48 R08: 00000000004002c8 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402070
R13: 0000000000402100 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9183:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_krealloc+0x84/0xc0 mm/kasan/common.c:565
 __do_krealloc mm/slab_common.c:1655 [inline]
 krealloc+0xa6/0xd0 mm/slab_common.c:1710
 nf_ct_ext_add+0x2c7/0x630 net/netfilter/nf_conntrack_extend.c:74
 nf_ct_ecache_ext_add include/net/netfilter/nf_conntrack_ecache.h:55 [inline]
 init_conntrack.isra.0+0x5ed/0x11a0 net/netfilter/nf_conntrack_core.c:1470
 resolve_normal_ct net/netfilter/nf_conntrack_core.c:1547 [inline]
 nf_conntrack_in+0xd94/0x1460 net/netfilter/nf_conntrack_core.c:1707
 ipv4_conntrack_local+0x127/0x220 net/netfilter/nf_conntrack_proto.c:200
 nf_hook_entry_hookfn include/linux/netfilter.h:135 [inline]
 nf_hook_slow+0xbc/0x1e0 net/netfilter/core.c:512
 nf_hook include/linux/netfilter.h:262 [inline]
 __ip_local_out+0x403/0x870 net/ipv4/ip_output.c:114
 ip_local_out+0x2d/0x1b0 net/ipv4/ip_output.c:123
 ip_send_skb+0x42/0xf0 net/ipv4/ip_output.c:1559
 udp_send_skb.isra.0+0x6d5/0x11b0 net/ipv4/udp.c:891
 udp_sendmsg+0x1e8f/0x2810 net/ipv4/udp.c:1178
 inet_sendmsg+0x9e/0xe0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 kernel_sendmsg+0x44/0x50 net/socket.c:678
 rxrpc_send_data_packet+0x10cb/0x36b0 net/rxrpc/output.c:416
 rxrpc_queue_packet net/rxrpc/sendmsg.c:220 [inline]
 rxrpc_send_data+0x1097/0x4130 net/rxrpc/sendmsg.c:427
 rxrpc_do_sendmsg+0xb8e/0x1d5f net/rxrpc/sendmsg.c:736
 rxrpc_sendmsg+0x4d6/0x5f0 net/rxrpc/af_rxrpc.c:585
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2312
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2414
 __do_sys_sendmmsg net/socket.c:2443 [inline]
 __se_sys_sendmmsg net/socket.c:2440 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2440
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9183:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 nf_ct_ext_destroy+0x2ab/0x2e0 net/netfilter/nf_conntrack_extend.c:38
 nf_conntrack_free+0x8f/0xe0 net/netfilter/nf_conntrack_core.c:1418
 destroy_conntrack+0x1a2/0x270 net/netfilter/nf_conntrack_core.c:626
 nf_conntrack_destroy+0xed/0x230 net/netfilter/core.c:600
 nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:34 [inline]
 nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:31 [inline]
 nf_ct_resolve_clash net/netfilter/nf_conntrack_core.c:915 [inline]
 __nf_conntrack_confirm+0x21ca/0x2830 net/netfilter/nf_conntrack_core.c:1038
 nf_conntrack_confirm include/net/netfilter/nf_conntrack_core.h:63 [inline]
 nf_confirm+0x3e7/0x4d0 net/netfilter/nf_conntrack_proto.c:154
 ipv4_confirm+0x14c/0x240 net/netfilter/nf_conntrack_proto.c:169
 nf_hook_entry_hookfn include/linux/netfilter.h:135 [inline]
 nf_hook_slow+0xbc/0x1e0 net/netfilter/core.c:512
 nf_hook include/linux/netfilter.h:262 [inline]
 NF_HOOK_COND include/linux/netfilter.h:295 [inline]
 ip_output+0x40d/0x670 net/ipv4/ip_output.c:432
 dst_output include/net/dst.h:436 [inline]
 ip_local_out+0xbb/0x1b0 net/ipv4/ip_output.c:125
 ip_send_skb+0x42/0xf0 net/ipv4/ip_output.c:1559
 udp_send_skb.isra.0+0x6d5/0x11b0 net/ipv4/udp.c:891
 udp_sendmsg+0x1e8f/0x2810 net/ipv4/udp.c:1178
 inet_sendmsg+0x9e/0xe0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 kernel_sendmsg+0x44/0x50 net/socket.c:678
 rxrpc_send_data_packet+0x10cb/0x36b0 net/rxrpc/output.c:416
 rxrpc_queue_packet net/rxrpc/sendmsg.c:220 [inline]
 rxrpc_send_data+0x1097/0x4130 net/rxrpc/sendmsg.c:427
 rxrpc_do_sendmsg+0xb8e/0x1d5f net/rxrpc/sendmsg.c:736
 rxrpc_sendmsg+0x4d6/0x5f0 net/rxrpc/af_rxrpc.c:585
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:658
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2312
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2414
 __do_sys_sendmmsg net/socket.c:2443 [inline]
 __se_sys_sendmmsg net/socket.c:2440 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2440
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809bad1000
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 4 bytes inside of
 128-byte region [ffff88809bad1000, ffff88809bad1080)
The buggy address belongs to the page:
page:ffffea00026eb440 refcount:1 mapcount:0 mapping:ffff8880aa400700 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002920f88 ffffea00025a6c08 ffff8880aa400700
raw: 0000000000000000 ffff88809bad1000 0000000100000010 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809bad0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809bad0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809bad1000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88809bad1080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809bad1100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (169):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/27 09:11 linux-next 139c2d13c258 25bb509e .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/10/24 21:25 linux-next 12d61c699699 d01bb02a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/10/28 10:07 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/28 06:56 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/28 05:52 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 23:21 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 19:25 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 17:23 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 16:42 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 14:03 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 13:00 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 11:11 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 06:34 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/27 01:54 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 22:31 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 18:21 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 15:23 linux-next 139c2d13c258 25bb509e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 14:59 linux-next 139c2d13c258 413926c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 12:22 linux-next 139c2d13c258 413926c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 10:55 linux-next 139c2d13c258 413926c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 09:49 linux-next 139c2d13c258 413926c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 05:50 linux-next 139c2d13c258 413926c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/26 03:18 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 23:50 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 20:57 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 19:36 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 16:50 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 14:57 linux-next 139c2d13c258 c2e837da .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 13:53 linux-next 139c2d13c258 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 12:10 linux-next 139c2d13c258 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 10:47 linux-next 139c2d13c258 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 09:36 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 08:30 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 06:12 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 03:53 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/25 00:56 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 22:49 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 22:39 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 19:58 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 18:56 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 17:20 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 14:37 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 13:32 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 10:40 linux-next 12d61c699699 d01bb02a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 06:58 linux-next 12d61c699699 b602d64b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 05:34 linux-next f3c452cfc59c b602d64b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 05:17 linux-next f3c452cfc59c b602d64b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/24 04:03 linux-next f3c452cfc59c b602d64b .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/21 07:46 linux-next a6fcdcd94927 8c88c9c1 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.