Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4827066yba; Tue, 30 Apr 2019 05:08:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDWIjuF/jH3ad8XZeyMcfPg2t0lOvisg5xnHgyU9boaBKXX5LCBR3CKTJd51DOV7taFtzv X-Received: by 2002:a17:902:be09:: with SMTP id r9mr69502377pls.215.1556626124410; Tue, 30 Apr 2019 05:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556626124; cv=none; d=google.com; s=arc-20160816; b=oJMEk1ytEWs2IEZzBXj7UgCPNdIrw5hzmjE1i3VBZrQX6r1fqJba8AQea8C2+/HfLz 9OcYbL+zMGg3Ho6kZ3f/uQvk/nrsltQrQEQhkVFGwgKXsc+m7s3TnS4nECfxsi0qv180 c6broa3EOuwwt90IKUrKQRrU8t77XWXk46M3TblQbYdKpdW5k+xpHTIpy0/hwcdvwr0X 9jHmJqWLPEG1ir+nwi3u6fxwi1K+QwgLiXunuA+8qcVJHCkEm1gCb2EwCw5+abFQwpW+ 4I8ntlJdLQAHCUmNY6Zg8HvW3i423uJqd9cSoNoPFizaBqx0V6Alql+9FjsOSPfeJhIl du/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lVivlKD33TTPoNZ7EkYsYVncZzQAXvhTozlsNF4KvA0=; b=RcnwT2jVlYFj80DjPqg11K9CvTBiU/mGHPDB8Laq0IDGJuesA/YUe5oAShoYuKFtOP 7c6K98HfqKp6MmdZHrw34pvFbVI/Zj2dbTkvuBGaOsECCOPOE4mRx5CgIJRK/qTQ2l+V bsR7jztheXjwV7TQcssuHD1RyJIBUOQ33gGQZxdYY4rGm2xRDYvWSMeD0kHfH+B2ZDpV LuXP6XYGUd07ofL6Pys8lo13AlRF+b8CB2d7je29JklwHCBIqmgVFiH8uDxE0IVWDt0y 40F8WYd26vq2JvoswqmVqv48Aey20b88XNQg0qgwVBVaIIKlDbngFlHpWLWps2GAK+az ap6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TAgGokev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si17693576pgv.378.2019.04.30.05.08.25; Tue, 30 Apr 2019 05:08:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TAgGokev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728587AbfD3Lkq (ORCPT + 99 others); Tue, 30 Apr 2019 07:40:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728553AbfD3Lkm (ORCPT ); Tue, 30 Apr 2019 07:40:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AB5E21734; Tue, 30 Apr 2019 11:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624441; bh=l29YY1Rymz3m8x+jhuKgXK4LbsFp8dBLSIzRwVLWfJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAgGokevZ0i1NGCOp7H7+rwJLRjPecTGL3J8WCOOWxs6cgVs7Dvi0IwyjAL5rAYUR 2+/7QFOrvCpDE+RyIdv/Dmd2Zw1+96tyDJgaVY5iqeD4qDkUI8EHtPRkacMl+sxcaX xdJE/FsCbULIAEtCchO6/Lp0PtLApvljujMNAW38= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 37/41] ipv6: frags: fix a lockdep false positive Date: Tue, 30 Apr 2019 13:38:48 +0200 Message-Id: <20190430113533.485703861@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113524.451237916@linuxfoundation.org> References: <20190430113524.451237916@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 415787d7799f4fccbe8d49cb0b8e5811be6b0389 ] lockdep does not know that the locks used by IPv4 defrag and IPv6 reassembly units are of different classes. It complains because of following chains : 1) sch_direct_xmit() (lock txq->_xmit_lock) dev_hard_start_xmit() xmit_one() dev_queue_xmit_nit() packet_rcv_fanout() ip_check_defrag() ip_defrag() spin_lock() (lock frag queue spinlock) 2) ip6_input_finish() ipv6_frag_rcv() (lock frag queue spinlock) ip6_frag_queue() icmpv6_param_prob() (lock txq->_xmit_lock at some point) We could add lockdep annotations, but we also can make sure IPv6 calls icmpv6_param_prob() only after the release of the frag queue spinlock, since this naturally makes frag queue spinlock a leaf in lock hierarchy. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/reassembly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -169,7 +169,8 @@ fq_find(struct net *net, __be32 id, cons } static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, - struct frag_hdr *fhdr, int nhoff) + struct frag_hdr *fhdr, int nhoff, + u32 *prob_offset) { struct sk_buff *prev, *next; struct net_device *dev; @@ -185,11 +186,7 @@ static int ip6_frag_queue(struct frag_qu ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1))); if ((unsigned int)end > IPV6_MAXPLEN) { - __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), - IPSTATS_MIB_INHDRERRORS); - icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, - ((u8 *)&fhdr->frag_off - - skb_network_header(skb))); + *prob_offset = (u8 *)&fhdr->frag_off - skb_network_header(skb); return -1; } @@ -220,10 +217,7 @@ static int ip6_frag_queue(struct frag_qu /* RFC2460 says always send parameter problem in * this case. -DaveM */ - __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), - IPSTATS_MIB_INHDRERRORS); - icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, - offsetof(struct ipv6hdr, payload_len)); + *prob_offset = offsetof(struct ipv6hdr, payload_len); return -1; } if (end > fq->q.len) { @@ -524,15 +518,22 @@ static int ipv6_frag_rcv(struct sk_buff iif = skb->dev ? skb->dev->ifindex : 0; fq = fq_find(net, fhdr->identification, hdr, iif); if (fq) { + u32 prob_offset = 0; int ret; spin_lock(&fq->q.lock); fq->iif = iif; - ret = ip6_frag_queue(fq, skb, fhdr, IP6CB(skb)->nhoff); + ret = ip6_frag_queue(fq, skb, fhdr, IP6CB(skb)->nhoff, + &prob_offset); spin_unlock(&fq->q.lock); inet_frag_put(&fq->q); + if (prob_offset) { + __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), + IPSTATS_MIB_INHDRERRORS); + icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, prob_offset); + } return ret; }