From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50CCDC10F11 for ; Wed, 24 Apr 2019 08:27:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27C89218DA for ; Wed, 24 Apr 2019 08:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728221AbfDXI1N convert rfc822-to-8bit (ORCPT ); Wed, 24 Apr 2019 04:27:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43854 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbfDXI1N (ORCPT ); Wed, 24 Apr 2019 04:27:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B6CF622E62; Wed, 24 Apr 2019 08:27:12 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-98.rdu2.redhat.com [10.10.121.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FF6A5D705; Wed, 24 Apr 2019 08:27:11 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20190424004741.152547-1-edumazet@google.com> References: <20190424004741.152547-1-edumazet@google.com> To: Eric Dumazet Cc: dhowells@redhat.com, "David S . Miller" , netdev , Eric Dumazet , syzbot Subject: Re: [PATCH v3 net] rxrpc: fix race condition in rxrpc_input_packet() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27702.1556094430.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Wed, 24 Apr 2019 09:27:10 +0100 Message-ID: <27703.1556094430@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 24 Apr 2019 08:27:12 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Eric Dumazet wrote: > After commit 5271953cad31 ("rxrpc: Use the UDP encap_rcv hook"), > rxrpc_input_packet() is directly called from lockless UDP receive > path, under rcu_read_lock() protection. > > It must therefore use RCU rules : > > - udp_sk->sk_user_data can be cleared at any point in this function. > rcu_dereference_sk_user_data() is what we need here. > > - Also, since sk_user_data might have been set in rxrpc_open_socket() > we must observe a proper RCU grace period before kfree(local) in > rxrpc_lookup_local() > > syzbot reported : > > kasan: CONFIG_KASAN_INLINE enabled > kasan: GPF could be caused by NULL-ptr deref or user memory access > general protection fault: 0000 [#1] PREEMPT SMP KASAN > CPU: 0 PID: 19236 Comm: syz-executor703 Not tainted 5.1.0-rc6 #79 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > RIP: 0010:__lock_acquire+0xbef/0x3fb0 kernel/locking/lockdep.c:3573 > Code: 00 0f 85 a5 1f 00 00 48 81 c4 10 01 00 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 48 b8 00 00 00 00 00 fc ff df 4c 89 ea 48 c1 ea 03 <80> 3c 02 00 0f 85 4a 21 00 00 49 81 7d 00 20 54 9c 89 0f 84 cf f4 > RSP: 0018:ffff88809d7aef58 EFLAGS: 00010002 > RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000 > RDX: 0000000000000026 RSI: 0000000000000000 RDI: 0000000000000001 > RBP: ffff88809d7af090 R08: 0000000000000001 R09: 0000000000000001 > R10: ffffed1015d05bc7 R11: ffff888089428600 R12: 0000000000000000 > R13: 0000000000000130 R14: 0000000000000001 R15: 0000000000000001 > FS: 00007f059044d700(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00000000004b6040 CR3: 00000000955ca000 CR4: 00000000001406f0 > Call Trace: > lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4211 > __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] > _raw_spin_lock_irqsave+0x95/0xcd kernel/locking/spinlock.c:152 > skb_queue_tail+0x26/0x150 net/core/skbuff.c:2972 > rxrpc_reject_packet net/rxrpc/input.c:1126 [inline] > rxrpc_input_packet+0x4a0/0x5536 net/rxrpc/input.c:1414 > udp_queue_rcv_one_skb+0xaf2/0x1780 net/ipv4/udp.c:2011 > udp_queue_rcv_skb+0x128/0x730 net/ipv4/udp.c:2085 > udp_unicast_rcv_skb.isra.0+0xb9/0x360 net/ipv4/udp.c:2245 > __udp4_lib_rcv+0x701/0x2ca0 net/ipv4/udp.c:2301 > udp_rcv+0x22/0x30 net/ipv4/udp.c:2482 > ip_protocol_deliver_rcu+0x60/0x8f0 net/ipv4/ip_input.c:208 > ip_local_deliver_finish+0x23b/0x390 net/ipv4/ip_input.c:234 > NF_HOOK include/linux/netfilter.h:289 [inline] > NF_HOOK include/linux/netfilter.h:283 [inline] > ip_local_deliver+0x1e9/0x520 net/ipv4/ip_input.c:255 > dst_input include/net/dst.h:450 [inline] > ip_rcv_finish+0x1e1/0x300 net/ipv4/ip_input.c:413 > NF_HOOK include/linux/netfilter.h:289 [inline] > NF_HOOK include/linux/netfilter.h:283 [inline] > ip_rcv+0xe8/0x3f0 net/ipv4/ip_input.c:523 > __netif_receive_skb_one_core+0x115/0x1a0 net/core/dev.c:4987 > __netif_receive_skb+0x2c/0x1c0 net/core/dev.c:5099 > netif_receive_skb_internal+0x117/0x660 net/core/dev.c:5202 > napi_frags_finish net/core/dev.c:5769 [inline] > napi_gro_frags+0xade/0xd10 net/core/dev.c:5843 > tun_get_user+0x2f24/0x3fb0 drivers/net/tun.c:1981 > tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2027 > call_write_iter include/linux/fs.h:1866 [inline] > do_iter_readv_writev+0x5e1/0x8e0 fs/read_write.c:681 > do_iter_write fs/read_write.c:957 [inline] > do_iter_write+0x184/0x610 fs/read_write.c:938 > vfs_writev+0x1b3/0x2f0 fs/read_write.c:1002 > do_writev+0x15e/0x370 fs/read_write.c:1037 > __do_sys_writev fs/read_write.c:1110 [inline] > __se_sys_writev fs/read_write.c:1107 [inline] > __x64_sys_writev+0x75/0xb0 fs/read_write.c:1107 > do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > Fixes: 5271953cad31 ("rxrpc: Use the UDP encap_rcv hook") > Signed-off-by: Eric Dumazet > Reported-by: syzbot Acked-by: David Howells