From owner-svn-src-head@freebsd.org Fri Nov 15 21:44:19 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C84DF1B133B; Fri, 15 Nov 2019 21:44:19 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47FBh31TrVz4R3N; Fri, 15 Nov 2019 21:44:19 +0000 (UTC) (envelope-from bz@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 C2B1F1F3CC; Fri, 15 Nov 2019 21:44:18 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAFLiIDw001395; Fri, 15 Nov 2019 21:44:18 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAFLiHop001392; Fri, 15 Nov 2019 21:44:17 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201911152144.xAFLiHop001392@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Fri, 15 Nov 2019 21:44:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354749 - in head/sys: netinet netinet6 netipsec X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in head/sys: netinet netinet6 netipsec X-SVN-Commit-Revision: 354749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2019 21:44:19 -0000 Author: bz Date: Fri Nov 15 21:44:17 2019 New Revision: 354749 URL: https://svnweb.freebsd.org/changeset/base/354749 Log: netinet*: replace IP6_EXTHDR_GET() In a few places we have IP6_EXTHDR_GET() left in upper layer protocols. The IP6_EXTHDR_GET() macro might perform an m_pulldown() in case the data fragment is not contiguous. Convert these last remaining instances into m_pullup()s instead. In CARP, for example, we will a few lines later call m_pullup() anyway, the IPsec code coming from OpenBSD would otherwise have done the m_pullup() and are copying the data a bit later anyway, so pulling it in seems no better or worse. Note: this leaves very few m_pulldown() cases behind in the tree and we might want to consider removing them as well to make mbuf management easier again on a path to variable size mbufs, especially given m_pulldown() still has an issue not re-checking M_WRITEABLE(). Reviewed by: gallatin MFC after: 8 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D22335 Modified: head/sys/netinet/ip_carp.c head/sys/netinet6/sctp6_usrreq.c head/sys/netipsec/xform_ah.c head/sys/netipsec/xform_esp.c Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Fri Nov 15 21:40:40 2019 (r354748) +++ head/sys/netinet/ip_carp.c Fri Nov 15 21:44:17 2019 (r354749) @@ -567,12 +567,13 @@ carp6_input(struct mbuf **mp, int *offp, int proto) /* verify that we have a complete carp packet */ len = m->m_len; - IP6_EXTHDR_GET(ch, struct carp_header *, m, *offp, sizeof(*ch)); - if (ch == NULL) { + m = m_pullup(m, *offp + sizeof(*ch)); + if (m == NULL) { CARPSTATS_INC(carps_badlen); CARP_DEBUG("%s: packet size %u too small\n", __func__, len); return (IPPROTO_DONE); } + ch = (struct carp_header *)(mtod(m, caddr_t) + *offp); /* verify the CARP checksum */ Modified: head/sys/netinet6/sctp6_usrreq.c ============================================================================== --- head/sys/netinet6/sctp6_usrreq.c Fri Nov 15 21:40:40 2019 (r354748) +++ head/sys/netinet6/sctp6_usrreq.c Fri Nov 15 21:44:17 2019 (r354749) @@ -103,13 +103,13 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, SCTP_STAT_INCR_COUNTER64(sctps_inpackets); /* Get IP, SCTP, and first chunk header together in the first mbuf. */ offset = iphlen + sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); - ip6 = mtod(m, struct ip6_hdr *); - IP6_EXTHDR_GET(sh, struct sctphdr *, m, iphlen, - (int)(sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr))); - if (sh == NULL) { + m = m_pullup(m, offset); + if (m == NULL) { SCTP_STAT_INCR(sctps_hdrops); return (IPPROTO_DONE); } + ip6 = mtod(m, struct ip6_hdr *); + sh = (struct sctphdr *)(mtod(m, caddr_t) + iphlen); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); offset -= sizeof(struct sctp_chunkhdr); memset(&src, 0, sizeof(struct sockaddr_in6)); Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Fri Nov 15 21:40:40 2019 (r354748) +++ head/sys/netipsec/xform_ah.c Fri Nov 15 21:44:17 2019 (r354749) @@ -575,14 +575,14 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski /* Figure out header size. */ rplen = HDRSIZE(sav); - /* XXX don't pullup, just copy header */ - IP6_EXTHDR_GET(ah, struct newah *, m, skip, rplen); - if (ah == NULL) { + m = m_pullup(m, skip + rplen); + if (m == NULL) { DPRINTF(("ah_input: cannot pullup header\n")); AHSTAT_INC(ahs_hdrops); /*XXX*/ error = ENOBUFS; goto bad; } + ah = (struct newah *)(mtod(m, caddr_t) + skip); /* Check replay window, if applicable. */ SECASVAR_LOCK(sav); Modified: head/sys/netipsec/xform_esp.c ============================================================================== --- head/sys/netipsec/xform_esp.c Fri Nov 15 21:40:40 2019 (r354748) +++ head/sys/netipsec/xform_esp.c Fri Nov 15 21:44:17 2019 (r354749) @@ -307,8 +307,15 @@ esp_input(struct mbuf *m, struct secasvar *sav, int sk ESPSTAT_INC(esps_badilen); goto bad; } - /* XXX don't pullup, just copy header */ - IP6_EXTHDR_GET(esp, struct newesp *, m, skip, sizeof (struct newesp)); + + m = m_pullup(m, skip + sizeof(*esp)); + if (m == NULL) { + DPRINTF(("%s: cannot pullup header\n", __func__)); + ESPSTAT_INC(esps_hdrops); /*XXX*/ + error = ENOBUFS; + goto bad; + } + esp = (struct newesp *)(mtod(m, caddr_t) + skip); esph = sav->tdb_authalgxform; espx = sav->tdb_encalgxform;