aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-03-23 13:38:59 +0000
committerMark Johnston <markj@FreeBSD.org>2021-03-26 16:33:12 +0000
commitfa6d101e5f67246a6804577a9532676eae64c049 (patch)
tree1167180dcfb4f45842e2240cb13ac28776918e2a /sys
parentc9b4e5e9ae398f3bb8ba85507d9710d8a73a1a04 (diff)
downloadsrc-fa6d101e5f67246a6804577a9532676eae64c049.tar.gz
src-fa6d101e5f67246a6804577a9532676eae64c049.zip
pf: Handle unmapped mbufs when computing checksums
Approved by: re (cperciva) PR: 254419 Reviewed by: gallatin, kp Tested by: Igor A. Valkov <viaprog@gmail.com> Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29378 (cherry picked from commit b93a796b06ec013a75a08ac43d8acf6aa94aa970) (cherry picked from commit 5fcab6fbcf8b99d1420e681731a07670c38defe3)
Diffstat (limited to 'sys')
-rw-r--r--sys/netpfil/pf/pf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 4cccb0101650..0ff3e541ca20 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -5555,11 +5555,17 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp,
/* Copied from FreeBSD 10.0-CURRENT ip_output. */
m0->m_pkthdr.csum_flags |= CSUM_IP;
if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) {
+ m0 = mb_unmapped_to_ext(m0);
+ if (m0 == NULL)
+ goto done;
in_delayed_cksum(m0);
m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
}
#if defined(SCTP) || defined(SCTP_SUPPORT)
if (m0->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) {
+ m0 = mb_unmapped_to_ext(m0);
+ if (m0 == NULL)
+ goto done;
sctp_delayed_cksum(m0, (uint32_t)(ip->ip_hl << 2));
m0->m_pkthdr.csum_flags &= ~CSUM_SCTP;
}
@@ -5717,6 +5723,9 @@ pf_route6(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp,
if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6 &
~ifp->if_hwassist) {
uint32_t plen = m0->m_pkthdr.len - sizeof(*ip6);
+ m0 = mb_unmapped_to_ext(m0);
+ if (m0 == NULL)
+ goto done;
in6_delayed_cksum(m0, plen, sizeof(struct ip6_hdr));
m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6;
}