From owner-svn-src-all@freebsd.org Thu Jun 28 11:39:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59181102E2F6; Thu, 28 Jun 2018 11:39:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0510877865; Thu, 28 Jun 2018 11:39:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B556011B10; Thu, 28 Jun 2018 11:39:28 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5SBdSsk048801; Thu, 28 Jun 2018 11:39:28 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5SBdRfB048795; Thu, 28 Jun 2018 11:39:27 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201806281139.w5SBdRfB048795@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 28 Jun 2018 11:39:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335760 - in head/sys: net netinet netinet6 X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in head/sys: net netinet netinet6 X-SVN-Commit-Revision: 335760 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 11:39:29 -0000 Author: ae Date: Thu Jun 28 11:39:27 2018 New Revision: 335760 URL: https://svnweb.freebsd.org/changeset/base/335760 Log: Add NULL pointer check. encap_lookup_t method can be invoked by IP encap subsytem even if none of gif/gre/me interfaces are exist. Hash tables are allocated on demand, when first interface is created. So, make NULL pointer check before doing access to hash table. PR: 229378 Modified: head/sys/net/if_me.c head/sys/netinet/in_gif.c head/sys/netinet/ip_gre.c head/sys/netinet6/in6_gif.c head/sys/netinet6/ip6_gre.c Modified: head/sys/net/if_me.c ============================================================================== --- head/sys/net/if_me.c Thu Jun 28 09:42:30 2018 (r335759) +++ head/sys/net/if_me.c Thu Jun 28 11:39:27 2018 (r335760) @@ -312,6 +312,9 @@ me_lookup(const struct mbuf *m, int off, int proto, vo const struct ip *ip; struct me_softc *sc; + if (V_me_hashtbl == NULL) + return (0); + MPASS(in_epoch()); ip = mtod(m, const struct ip *); CK_LIST_FOREACH(sc, &ME_HASH(ip->ip_dst.s_addr, Modified: head/sys/netinet/in_gif.c ============================================================================== --- head/sys/netinet/in_gif.c Thu Jun 28 09:42:30 2018 (r335759) +++ head/sys/netinet/in_gif.c Thu Jun 28 11:39:27 2018 (r335760) @@ -289,6 +289,9 @@ in_gif_lookup(const struct mbuf *m, int off, int proto struct gif_softc *sc; int ret; + if (V_ipv4_hashtbl == NULL) + return (0); + MPASS(in_epoch()); ip = mtod(m, const struct ip *); /* Modified: head/sys/netinet/ip_gre.c ============================================================================== --- head/sys/netinet/ip_gre.c Thu Jun 28 09:42:30 2018 (r335759) +++ head/sys/netinet/ip_gre.c Thu Jun 28 11:39:27 2018 (r335760) @@ -115,6 +115,9 @@ in_gre_lookup(const struct mbuf *m, int off, int proto const struct ip *ip; struct gre_softc *sc; + if (V_ipv4_hashtbl == NULL) + return (0); + MPASS(in_epoch()); ip = mtod(m, const struct ip *); CK_LIST_FOREACH(sc, &GRE_HASH(ip->ip_dst.s_addr, Modified: head/sys/netinet6/in6_gif.c ============================================================================== --- head/sys/netinet6/in6_gif.c Thu Jun 28 09:42:30 2018 (r335759) +++ head/sys/netinet6/in6_gif.c Thu Jun 28 11:39:27 2018 (r335760) @@ -309,6 +309,9 @@ in6_gif_lookup(const struct mbuf *m, int off, int prot struct gif_softc *sc; int ret; + if (V_ipv6_hashtbl == NULL) + return (0); + MPASS(in_epoch()); /* * NOTE: it is safe to iterate without any locking here, because softc Modified: head/sys/netinet6/ip6_gre.c ============================================================================== --- head/sys/netinet6/ip6_gre.c Thu Jun 28 09:42:30 2018 (r335759) +++ head/sys/netinet6/ip6_gre.c Thu Jun 28 11:39:27 2018 (r335760) @@ -107,6 +107,9 @@ in6_gre_lookup(const struct mbuf *m, int off, int prot const struct ip6_hdr *ip6; struct gre_softc *sc; + if (V_ipv6_hashtbl == NULL) + return (0); + MPASS(in_epoch()); ip6 = mtod(m, const struct ip6_hdr *); CK_LIST_FOREACH(sc, &GRE_HASH(&ip6->ip6_dst, &ip6->ip6_src), chain) {