From nobody Tue Nov 30 17:36:13 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6156E18B648B; Tue, 30 Nov 2021 17:36:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3TsV0Bh5z4sKG; Tue, 30 Nov 2021 17:36:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D089D1A3FC; Tue, 30 Nov 2021 17:36:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AUHaDw3034580; Tue, 30 Nov 2021 17:36:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AUHaD75034579; Tue, 30 Nov 2021 17:36:13 GMT (envelope-from git) Date: Tue, 30 Nov 2021 17:36:13 GMT Message-Id: <202111301736.1AUHaD75034579@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 439da7f06dce - main - if_stf: KASAN fix List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 439da7f06dcea5af17e7d5b3b4784e54207194ac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638293774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RNFKg5HlAPfQEfDdP6C8xsK1l+C+nYWaEZowy+495Cg=; b=iMjHK/pc83Qf+sbZsVEQPajDPAOz1IsJmwAgSdBDos9pxeAX6EpIanB34BDf4CY0z2eALJ M3X0eBczZ3o7koWnp8//LFApRsdjyLE6e2PT0NXhez/bhbw+ly88fbwEXmlcI77GAM0oJV BGSfXUpFdeD6PKIRbPsLiXb7JCgTjvpcm0lVEZHfWbD15CUkmumqgm4DpFK9JmgL74iDPj n7qkAiCJIBq7v/RvC6STsRlfyayT2YQPD6cC/8QKl3IFyPuL8N9xdK4veuCWfRz4y27OOM fh/pishOdQEZZH2EOWFcG2LBeoxI1OGvJDtHWAKUzbADBBNHUzEMtjoqsi2Nng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638293774; a=rsa-sha256; cv=none; b=FqEWBvpkX9R9WT7k9o+ZO4TUwjePfXYGgoTE8PntUYRxLE2vv2FDH4W3F5O2JlLPJQts6l wsjEJ7ECdpP/AT2BwK9xihzEsqMPE8gl8lmnlTB8HY22T7FB6KeIBoePsdTLAczn9FT/Yi 4kkRyt1zp2/NJ3eQzYd8RauMecDXHjWklnAcJLDCMhqzx97x821+eKkw2qYqiaXhirBI6g 4gQEvRUk2DBBB6dmy9rsSjyO4mIOj/sz0MM+4070Z6XI1cyy34HYyOX9bmNrXunzZZOq1/ iwWmwfJfZ/Dtznf/ThkDUjPE0E+uDBg2g9GhEE04Ukh4XKXNxHPibUHzKT1Vpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=439da7f06dcea5af17e7d5b3b4784e54207194ac commit 439da7f06dcea5af17e7d5b3b4784e54207194ac Author: Kristof Provost AuthorDate: 2021-11-30 15:30:22 +0000 Commit: Kristof Provost CommitDate: 2021-11-30 16:35:15 +0000 if_stf: KASAN fix In in_stf_input() we grabbed a pointer to the IPv4 header and later did an m_pullup() before we look at the IPv6 header. However, m_pullup() could rearrange the mbuf chain and potentially invalidate the pointer to the IPv4 header. Avoid this issue by copying the IP header rather than getting a pointer to it. Reported by: markj, Jenkins (KASAN job) Reviewed by: markj MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33192 --- sys/net/if_stf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 7807c6ebe7e9..51ea0a61ae0d 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -727,7 +727,7 @@ static int in_stf_input(struct mbuf *m, int off, int proto, void *arg) { struct stf_softc *sc = arg; - struct ip *ip; + struct ip ip; struct ip6_hdr *ip6; u_int8_t otos, itos; struct ifnet *ifp; @@ -743,7 +743,7 @@ in_stf_input(struct mbuf *m, int off, int proto, void *arg) return (IPPROTO_DONE); } - ip = mtod(m, struct ip *); + m_copydata(m, 0, sizeof(struct ip), (caddr_t)&ip); if (sc == NULL || (STF2IFP(sc)->if_flags & IFF_UP) == 0) { m_freem(m); SDT_PROBE2(if_stf, , stf_input, out, IPPROTO_DONE, __LINE__); @@ -760,14 +760,14 @@ in_stf_input(struct mbuf *m, int off, int proto, void *arg) * perform sanity check against outer src/dst. * for source, perform ingress filter as well. */ - if (stf_checkaddr4(sc, &ip->ip_dst, NULL) < 0 || - stf_checkaddr4(sc, &ip->ip_src, m->m_pkthdr.rcvif) < 0) { + if (stf_checkaddr4(sc, &ip.ip_dst, NULL) < 0 || + stf_checkaddr4(sc, &ip.ip_src, m->m_pkthdr.rcvif) < 0) { m_freem(m); SDT_PROBE2(if_stf, , stf_input, out, IPPROTO_DONE, __LINE__); return (IPPROTO_DONE); } - otos = ip->ip_tos; + otos = ip.ip_tos; m_adj(m, off); if (m->m_len < sizeof(*ip6)) { @@ -795,8 +795,8 @@ in_stf_input(struct mbuf *m, int off, int proto, void *arg) * reject packets with private address range. * (requirement from RFC3056 section 2 1st paragraph) */ - if ((IN6_IS_ADDR_6TO4(&ip6->ip6_src) && isrfc1918addr(&ip->ip_src)) || - (IN6_IS_ADDR_6TO4(&ip6->ip6_dst) && isrfc1918addr(&ip->ip_dst))) { + if ((IN6_IS_ADDR_6TO4(&ip6->ip6_src) && isrfc1918addr(&ip.ip_src)) || + (IN6_IS_ADDR_6TO4(&ip6->ip6_dst) && isrfc1918addr(&ip.ip_dst))) { m_freem(m); SDT_PROBE2(if_stf, , stf_input, out, IPPROTO_DONE, __LINE__); return (IPPROTO_DONE);