Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1156508yba; Wed, 24 Apr 2019 16:20:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy85h9QVSNXPwdH3KZu1U8R/D0pitIArEvKYWloYkktrb6ct8axcsEPx9QnVOb6M6HlsZCc X-Received: by 2002:a62:4852:: with SMTP id v79mr36330884pfa.72.1556148029822; Wed, 24 Apr 2019 16:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556148029; cv=none; d=google.com; s=arc-20160816; b=EPVRQRPwVMHj+AzVCx+45LHOklOhaX5igC3nXhS4+jb/tZ+T8FZmXniRoJ94tVXnxO gdEdm0BCGLxppG8inmlTAKfKjb+erc0c/tX3IdMYQ1SvConjWXf1JWuMjvcvN/SGkNES 1jpV4OH89mU4aX9yFN++Ydgc62qPuNZO6Oa76sviyL3sEJsMQ3Ni/i/faHskwkwVNy5U SGO7FoUJyIbkmgNXePOjbt7TeHoz2FaH0GUbnwG67QCYVrXd6PoDmWzlZcTA9YamR0kt GD7seiFVyCN41Ff7S0ol0M0fy3DXF/XU92vwkD4dc6a3pCQjHjnsygF5WLA+RhkyIkVe bPcQ== 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=ELquR7zxDV+wGeB0nN1yd3VJ7ZUtx6BMztS/1YKUC8Q=; b=ChgArHZxQGwmFuaCZxImrW1svcO1dd8Ac05JvtBwjt/SLBLNEHhNp9L5h5dEo7sfp0 BxwYL0sWvBnIZg+UoqOUftwYMVv790xmFhcjKxigDZ7pWzIgtn0WDdDdkqVlJnMXCTPv IVXSBlLgBxdAOTMfR0FI4e/plFF6vQpWOUTxc8jYDoO7whRPQqrxDLgmIUjiouMPbrOI ZHzJtqUB/tiuEFvm/kAuQIZSOsuc7EtB7cHF/FGWffX+hc4o6jKLiEjMKISotwXmA224 qDS8EzblPqU3qfZrjhw5JgSpuWidAqrgZ276llRjsC4tLhA0Dpeh6zMVGbLg2eocjFDb tggg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LjKYUUGQ; 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 b2si19755189pgn.93.2019.04.24.16.20.13; Wed, 24 Apr 2019 16:20:29 -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=LjKYUUGQ; 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 S2390670AbfDXR2X (ORCPT + 99 others); Wed, 24 Apr 2019 13:28:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:54522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390647AbfDXR2S (ORCPT ); Wed, 24 Apr 2019 13:28:18 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 C8EA1205ED; Wed, 24 Apr 2019 17:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126897; bh=3QSmPWTTFLyM3UhpPRdBhpNELUK98UsXtjcpVDVuTKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LjKYUUGQriKX8B2PgHtTX6DYWBqy2MWbA683PDac0twSg29Jz6nGwG2WluUlLSOaI 6k5jPKCOyXxujre8CVvW3iigXJerQmOTyl21457iQA8ETaO3NhrQk4egqY+dNxAtHW kHdCH/VjcqxxMTrtHvn7UiNjRqLkumZ1Xrk1pkMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 55/70] ipv6: frags: fix a lockdep false positive Date: Wed, 24 Apr 2019 19:10:15 +0200 Message-Id: <20190424170917.536456319@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170906.751869122@linuxfoundation.org> References: <20190424170906.751869122@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 [ 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: Sasha Levin --- net/ipv6/reassembly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 2a8c680b67cd..f75e9e711c31 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -170,7 +170,8 @@ fq_find(struct net *net, __be32 id, const struct ipv6hdr *hdr, int iif) } 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; @@ -186,11 +187,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ((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; } @@ -221,10 +218,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, /* 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) { @@ -536,15 +530,22 @@ static int ipv6_frag_rcv(struct sk_buff *skb) 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; } -- 2.19.1