From patchwork Wed Nov 18 20:40:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 546191 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6212314149E for ; Thu, 19 Nov 2015 07:40:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Lfp2nNwM; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757021AbbKRUkU (ORCPT ); Wed, 18 Nov 2015 15:40:20 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:34731 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756041AbbKRUkR (ORCPT ); Wed, 18 Nov 2015 15:40:17 -0500 Received: by padhx2 with SMTP id hx2so55571933pad.1 for ; Wed, 18 Nov 2015 12:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; bh=0vfdsD/gDkoIsBbPlEPijZDtutCcxdP+c0Cjbm82D+4=; b=Lfp2nNwM1flKr0jPp/X8r4W+sUlGS8ikGMPnDxVYbcwdUIDd1F8fddRUO6063ikjQt lnFWke138qVHYXJ9uqV8bXEJJAuhKYTtY/6J4zm88sOhz3W9NHy6XxYeSbmv0cE8rYao dm70EN14yNdLtYTpJ/UILd32u7G5vNaJdSWnkNKJjl+PD4lTp17PAiNpW1PiZ4ie8w+a 3n2PRul/iQD6sTvqA1M8OUh9r/vpMDeI9fAc3T9XdfKGmC+h6GpHY4q+JYc/lfnfq32q abQ2W5+mtNvrR83pohalbDuTfMCQgI6s1frS3Gvkh1fxewo/vi1I4UD2BKe3dxjIIyel uLgg== X-Received: by 10.66.141.73 with SMTP id rm9mr5021700pab.96.1447879216579; Wed, 18 Nov 2015 12:40:16 -0800 (PST) Received: from ?IPv6:2620:0:1000:3e02:5f5:1d29:b411:6e0c? ([2620:0:1000:3e02:5f5:1d29:b411:6e0c]) by smtp.gmail.com with ESMTPSA id hz4sm5944858pbc.12.2015.11.18.12.40.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Nov 2015 12:40:15 -0800 (PST) Message-ID: <1447879213.22599.182.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH net] tcp: md5: fix lockdep annotation From: Eric Dumazet To: David Miller Cc: netdev , Willem de Bruijn Date: Wed, 18 Nov 2015 12:40:13 -0800 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet When a passive TCP is created, we eventually call tcp_md5_do_add() with sk pointing to the child. It is not owner by the user yet (we will add this socket into listener accept queue a bit later anyway) But we do own the spinlock, so amend the lockdep annotation to avoid following splat : [ 8451.090932] net/ipv4/tcp_ipv4.c:923 suspicious rcu_dereference_protected() usage! [ 8451.090932] [ 8451.090932] other info that might help us debug this: [ 8451.090932] [ 8451.090934] [ 8451.090934] rcu_scheduler_active = 1, debug_locks = 1 [ 8451.090936] 3 locks held by socket_sockopt_/214795: [ 8451.090936] #0: (rcu_read_lock){.+.+..}, at: [] __netif_receive_skb_core+0x151/0xe90 [ 8451.090947] #1: (rcu_read_lock){.+.+..}, at: [] ip_local_deliver_finish+0x43/0x2b0 [ 8451.090952] #2: (slock-AF_INET){+.-...}, at: [] sk_clone_lock+0x1c5/0x500 [ 8451.090958] [ 8451.090958] stack backtrace: [ 8451.090960] CPU: 7 PID: 214795 Comm: socket_sockopt_ [ 8451.091215] Call Trace: [ 8451.091216] [] dump_stack+0x55/0x76 [ 8451.091229] [] lockdep_rcu_suspicious+0xeb/0x110 [ 8451.091235] [] tcp_md5_do_add+0x1bf/0x1e0 [ 8451.091239] [] tcp_v4_syn_recv_sock+0x1f1/0x4c0 [ 8451.091242] [] ? tcp_v4_md5_hash_skb+0x167/0x190 [ 8451.091246] [] tcp_check_req+0x3c8/0x500 [ 8451.091249] [] ? tcp_v4_inbound_md5_hash+0x11e/0x190 [ 8451.091253] [] tcp_v4_rcv+0x3c0/0x9f0 [ 8451.091256] [] ? ip_local_deliver_finish+0x43/0x2b0 [ 8451.091260] [] ip_local_deliver_finish+0xb6/0x2b0 [ 8451.091263] [] ? ip_local_deliver_finish+0x43/0x2b0 [ 8451.091267] [] ip_local_deliver+0x48/0x80 [ 8451.091270] [] ip_rcv_finish+0x160/0x700 [ 8451.091273] [] ip_rcv+0x29e/0x3d0 [ 8451.091277] [] __netif_receive_skb_core+0xb47/0xe90 Fixes: a8afca0329988 ("tcp: md5: protects md5sig_info with RCU") Signed-off-by: Eric Dumazet Reported-by: Willem de Bruijn --- net/ipv4/tcp_ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index ba09016d1bfd..db003438aaf5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -921,7 +921,8 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, } md5sig = rcu_dereference_protected(tp->md5sig_info, - sock_owned_by_user(sk)); + sock_owned_by_user(sk) || + lockdep_is_held(&sk->sk_lock.slock)); if (!md5sig) { md5sig = kmalloc(sizeof(*md5sig), gfp); if (!md5sig)