From nobody Wed Jul 23 14:23:46 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 4bnGb64v28z62P77; Wed, 23 Jul 2025 14:23:46 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bnGb61Fvjz3pW4; Wed, 23 Jul 2025 14:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753280626; 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=nwKFVNTVrRFBzbjP3EFB5gCf6lW2fudzDSWc5XfXO2c=; b=C7Xoqp3HM485QXjTw8T03iIDF6v+xY106aWVEgnYI0wmC6+AnLLDNb4N6dk+vZA3kMeVd2 CMdFCLM7gFHFIFUvm6UB1dYy4n7jh8ASunWwXiBp+zE/ozOnXWVW0SSFcl7p7D/LSFme6C T/P6+bkAdl1ULGRKJ0XPO5Op+4eWUX80eQg7rS9nyqVkeMnsrwVl/QHQQr6fuKn7IJ62z/ MRBhuzQAAyr0xwYx5eSSNYcY8bo45SRgL6N8nj4gIvuhxnOu6HpMWLpwniY1yJnWhIeL7B RyyM0jjAomEvRpN7meI+s1T3ciBMl7l/Lu20XN2cRNoJv7EW08AjbKCaRmXAfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753280626; 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=nwKFVNTVrRFBzbjP3EFB5gCf6lW2fudzDSWc5XfXO2c=; b=JACBMNHFBQC8KtaTi5cLvY9TgrlGLfEN/SgxC2AsdLkfOTBWDYvjDSbxyQtUyg9u8cgsh/ ora/tpsv9FtnN3fuayUgi2WbjhIxKI7Q2ro42WrFAAzSL2Rr8CwX5FcFja1F4S/D8tVite d54Gatu8PkiXdGfXziGFXJT/Z5HpVTZfJHPSMuTDX0cIo757SImc1geA3xijbDAhFK7AD6 qzDu+x8Flwdl6rNHlbR2liO9lJmSETnEalw6i3o56labsOoVnuXMtssWwoaSEgp8SE5ePA y8ZYEZjQ5Bg3SbGWWVCj25SbFyi8rWFGT9qTFOeCfrAEf6pmt4PUvrsDY0aYUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753280626; a=rsa-sha256; cv=none; b=AMU/OxV5jrng0IhYCucjr4hZTM/yZsrqtkHnqZfrpxD//Z3hEVnmLZ/z1DZzzIZUNDzroN xUR9XlKaZnkdUv1P+J0VUkAStccPD//nHKZl2yIOPvDLkYolC9fjWaBoAf1oLXlxubY+dZ 6uIwUxvk9meq4H5KGUocG93YqQEYuRNFk9CAje6rvEehKzHhT2aguXEHrbTLzBFKyCNgKC EKB156t+Jhoj0oLAE73MvrJHRayC6v/qgcB0U4zHjXa9ItHH0zZCK8tT+5+6A0eNSoITMx Euvceq5gF9GSNHGTFi8VSCkR+JcAw/MSV2DZoqDd1bb1qZ7nlyGDtMzYBOC4Tg== 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 4bnGb60sGSz1Lw; Wed, 23 Jul 2025 14:23:46 +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 56NENkdd031114; Wed, 23 Jul 2025 14:23:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56NENknb031111; Wed, 23 Jul 2025 14:23:46 GMT (envelope-from git) Date: Wed, 23 Jul 2025 14:23:46 GMT Message-Id: <202507231423.56NENknb031111@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: 986abfeb9358 - main - pf: run Jumbogram check before we walk the headers 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: 986abfeb9358011af892f177c102dd3249196e02 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=986abfeb9358011af892f177c102dd3249196e02 commit 986abfeb9358011af892f177c102dd3249196e02 Author: Kristof Provost AuthorDate: 2025-07-16 11:58:42 +0000 Commit: Kristof Provost CommitDate: 2025-07-23 13:35:43 +0000 pf: run Jumbogram check before we walk the headers While it is safe to run pf_walk_header6() on a packet with a 0 ip6_plen we're better off doing this check first. It's more obviously correct, and it's a very simple check to reject a packet. Suggested by: emaste Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 9517e9b8c9bc..1310445c4063 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -10149,6 +10149,15 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, return (-1); } + /* + * we do not support jumbogram. if we keep going, zero ip6_plen + * will do something bad, so drop the packet for now. + */ + if (htons(h->ip6_plen) == 0) { + *action = PF_DROP; + return (-1); + } + if (pf_walk_header6(pd, h, reason) != PF_PASS) { *action = PF_DROP; return (-1); @@ -10168,15 +10177,6 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, pd->virtual_proto = (pd->fragoff != 0) ? PF_VPROTO_FRAGMENT : pd->proto; - /* - * we do not support jumbogram. if we keep going, zero ip6_plen - * will do something bad, so drop the packet for now. - */ - if (htons(h->ip6_plen) == 0) { - *action = PF_DROP; - return (-1); - } - /* We do IP header normalization and packet reassembly here */ if (pf_normalize_ip6(pd->fragoff, reason, pd) != PF_PASS) {