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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS 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 88354C282C2 for ; Wed, 6 Feb 2019 15:00:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61709217F9 for ; Wed, 6 Feb 2019 15:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730989AbfBFPAh (ORCPT ); Wed, 6 Feb 2019 10:00:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47742 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfBFPAg (ORCPT ); Wed, 6 Feb 2019 10:00:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 568DFA0901; Wed, 6 Feb 2019 15:00:36 +0000 (UTC) Received: from localhost (ovpn-200-19.brq.redhat.com [10.40.200.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE06969100; Wed, 6 Feb 2019 15:00:34 +0000 (UTC) Date: Wed, 6 Feb 2019 16:00:30 +0100 From: Stefano Brivio To: Hangbin Liu Cc: netdev@vger.kernel.org, David Miller Subject: Re: [PATCH net 2/2] sit: check if IPv6 enabled before call ip6_err_gen_icmpv6_unreach() Message-ID: <20190206160030.4675570c@redhat.com> In-Reply-To: <20190206125111.5286-3-liuhangbin@gmail.com> References: <20190206125111.5286-1-liuhangbin@gmail.com> <20190206125111.5286-3-liuhangbin@gmail.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 06 Feb 2019 15:00:36 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 6 Feb 2019 20:51:11 +0800 Hangbin Liu wrote: > If we disabled IPv6 from kernel boot up cmd(ipv6.disable=1), we should not > call ip6_err_gen_icmpv6_unreach(). > > Reproducer: > ip link add sit1 type sit local 10.10.0.1 remote 10.10.1.1 ttl 1 > ip link set sit1 up > ip addr add 192.168.0.1/24 dev sit1 > ping 192.168.0.2 > > Reported-by: Jianlin Shi > Signed-off-by: Hangbin Liu > --- > net/ipv6/sit.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c > index 1e03305c0549..e43fbac0fd1a 100644 > --- a/net/ipv6/sit.c > +++ b/net/ipv6/sit.c > @@ -493,6 +493,7 @@ static int ipip6_err(struct sk_buff *skb, u32 info) > const int type = icmp_hdr(skb)->type; > const int code = icmp_hdr(skb)->code; > unsigned int data_len = 0; > + struct inet6_dev *idev; > struct ip_tunnel *t; > int sifindex; > int err; > @@ -546,8 +547,13 @@ static int ipip6_err(struct sk_buff *skb, u32 info) > } > > err = 0; > - if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) > + > + idev = in6_dev_get(skb->dev); > + if (idev && > + !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) { > + in6_dev_put(idev); > goto out; > + } You are leaking a reference if idev && ip6_err_gen_icmpv6_unreach(...). You should call in6_dev_put(idev) whenever idev is not NULL instead. -- Stefano