From nobody Thu Feb 06 14:00:16 2025 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 4Ypdz46wnSz5mTxk; Thu, 06 Feb 2025 14:00:16 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ypdz45QZPz3dCL; Thu, 06 Feb 2025 14:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738850416; 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=jZ7DIdpTt2xSUNzBSHCTLrQt1pDrXCl+ZQqyPH6mc8I=; b=lOz7NLUZwcAPtQMOV166ul/OtBWOLOB9kE2bl1TaXlX6Kp3d7GArpEyOb4gPeZK7eyD6tz r0Oa/i1j3rxpv3m0+i4yEYBicmXcs+ZLLm+dl356vb1JlANfHiwHqKECQo01dxQDubp/XZ gwT1Y6gYiW9afP7hBICm+I6bsB+msVH5drm48SOPV2PjGD18+4qqp05I1ioqxFCq/fo7MZ 2dp+BKjtqrvly9mpFdHwdqtJJ/w8MiG2+hvp5AJjAGqMx4w5gr010VQj0PssTPGbooZspK SBFE/hHremC0cBPZJtQAuoVd9kW/vNzBX013vAoaYI+WM9aGXtaG5TTCwnnY4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738850416; 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=jZ7DIdpTt2xSUNzBSHCTLrQt1pDrXCl+ZQqyPH6mc8I=; b=YvbbctQA9yrqwoSOMzhGKa6zjJwC24Qu5O3v3gg46mcLTIdMRFPN6AhKnTjdiwfCDHnkoQ eqd4Ns+StQyTQ1OwiyDHvDvvGFZ3qM1pkHlcGosrRD3iHhbQbWzGKZwhoPGDe/0uHXJ81Q BFMFvPw+KiLZkNOmbRcMcVFXQm2/Z1tEkoNjBSAYg3RPvQZRBllVs/qaBNnrmhF0QYW5f2 P09TqVMNidGVk3eZ1FwX5F0RxQ4nXatoJuKtGry0slhw6kSiKXtnCgeBFtM5k4JST+kFYd p5Cv74pzP1RFAWo0V4z3N1k/WgkwEGzplpkmMEXKicH4rQX52FTdQ57yPskA0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738850416; a=rsa-sha256; cv=none; b=MSnzw7yy8BR2r40XTtLSC+qMXUapzDdRVHWCe93jOw8JK4PZoEziRQwu7ZcxNXWjGy8SmK 1zqi4EpFjHIbm05dfYD1d2J7E2yZJd8jgdHqOTvhyAaC51nts+7J9vb/KjGWuubWNadyQ7 C/4LJGNnEDxGhzOyQkEw0QpRoutwwAJf4aZSDQuJfF41qPCHsMr7VIyLAc4fQ86IAtkb+m 6DZ96XO+Rk5NqgqNxDCg5v7k6p7zSsynOgGe2HTpJegwviraeO/tGb8NuLY2FM8Xon99gI N/OxwzsI1FrmWjR5K9OqQpybUpH5bOYaoGoP9Ak31bHAzbxCLVIumECZQpdq3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4Ypdz44yJkzhMQ; Thu, 06 Feb 2025 14:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 516E0G3B022861; Thu, 6 Feb 2025 14:00:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 516E0GFU022846; Thu, 6 Feb 2025 14:00:16 GMT (envelope-from git) Date: Thu, 6 Feb 2025 14:00:16 GMT Message-Id: <202502061400.516E0GFU022846@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: 5a79138b3884 - main - pf: fix quoted ip packet length for af-to 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 5a79138b3884d9c5ef91d265f8c605f930cd113e Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5a79138b3884d9c5ef91d265f8c605f930cd113e commit 5a79138b3884d9c5ef91d265f8c605f930cd113e Author: Kristof Provost AuthorDate: 2025-02-03 10:16:11 +0000 Commit: Kristof Provost CommitDate: 2025-02-06 14:00:05 +0000 pf: fix quoted ip packet length for af-to With address family translation, the ip length of the quoted ip packet within the icmp error packet was wrong. Fix this by using the pd2.tot_len of the inner packet and substract the old header's length. OK mikeb@ henning@ Obtained from: OpenBSD, bluhm , 3d0247e0e8 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index d78978a75317..1cfd1a11db53 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -3566,8 +3566,6 @@ pf_change_icmp_af(struct mbuf *m, int off, struct pf_pdesc *pd, olen = pd2->off - off; /* new header */ hlen = naf == AF_INET ? sizeof(*ip4) : sizeof(*ip6); - /* data lenght */ - mlen = m->m_pkthdr.len - pd2->off; /* trim old header */ m_adj(n, olen); @@ -3584,7 +3582,7 @@ pf_change_icmp_af(struct mbuf *m, int off, struct pf_pdesc *pd, bzero(ip4, sizeof(*ip4)); ip4->ip_v = IPVERSION; ip4->ip_hl = sizeof(*ip4) >> 2; - ip4->ip_len = htons(sizeof(*ip4) + mlen); + ip4->ip_len = htons(sizeof(*ip4) + pd2->tot_len - olen); ip_fillid(ip4); ip4->ip_off = htons(IP_DF); ip4->ip_ttl = pd2->ttl; @@ -3600,7 +3598,7 @@ pf_change_icmp_af(struct mbuf *m, int off, struct pf_pdesc *pd, ip6 = mtod(n, struct ip6_hdr *); bzero(ip6, sizeof(*ip6)); ip6->ip6_vfc = IPV6_VERSION; - ip6->ip6_plen = htons(mlen); + ip6->ip6_plen = htons(pd2->tot_len - olen); if (pd2->proto == IPPROTO_ICMP) ip6->ip6_nxt = IPPROTO_ICMPV6; else @@ -7936,6 +7934,7 @@ pf_test_state_icmp(struct pf_kstate **state, struct pf_pdesc *pd, pd2.off = ipoff2 + (h2.ip_hl << 2); pd2.proto = h2.ip_p; + pd2.tot_len = ntohs(h2.ip_len); pd2.src = (struct pf_addr *)&h2.ip_src; pd2.dst = (struct pf_addr *)&h2.ip_dst; pd2.ip_sum = &h2.ip_sum; @@ -7956,6 +7955,8 @@ pf_test_state_icmp(struct pf_kstate **state, struct pf_pdesc *pd, if (pf_walk_header6(&pd2, &h2_6, reason) != PF_PASS) return (PF_DROP); + pd2.tot_len = ntohs(h2_6.ip6_plen) + + sizeof(struct ip6_hdr); pd2.src = (struct pf_addr *)&h2_6.ip6_src; pd2.dst = (struct pf_addr *)&h2_6.ip6_dst; pd2.ip_sum = NULL;