From nobody Fri Mar 25 12:53:56 2022 X-Original-To: dev-commits-src-all@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 07B961A43590; Fri, 25 Mar 2022 12:53:57 +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 4KQ28h6bT7z4tyh; Fri, 25 Mar 2022 12:53:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648212836; 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=ij7jwhNxwyUGjai6WqTSYx+dGZAyzwqShnYRjOB6xKc=; b=Y3Uepc4BUfXuTzarvBzmPV6fAz/M85rg8+uTDyu7nKbpvHb6iVTfKO7RhugHVkVaVXkZ+Z Qa+H+Te8gIejMf5nTWQnvMyFqtU690NWDekId11Xkkmu+P6gVXTG8RlfMRLZn3cXWpc4R5 VxhefFRRu+K6xPvqGswv9fhcr0YbXdC4nXPn0yCSdgJnPm/d36P41PIgcuNm1KB39QxRRv EmjgaiBPEgxlsa4BBXZA0y3PD3bpn0Hy4BHLykRuRTnb+Zkt1lKI3oP4DqBLGPft9Gj07x tByU2kmh+J/1mB2uCVQJtRfkhuzmvgW/UH8N9B4p4nqSZ4T4G1zq3oXpoKqVfw== 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 B7F16447B; Fri, 25 Mar 2022 12:53:56 +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 22PCruZt046862; Fri, 25 Mar 2022 12:53:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22PCruqb046861; Fri, 25 Mar 2022 12:53:56 GMT (envelope-from git) Date: Fri, 25 Mar 2022 12:53:56 GMT Message-Id: <202203251253.22PCruqb046861@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: 3468cd95ca12 - main - pf: ether l3 rules can only use addresses List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 3468cd95ca1249946bace931f2035e76b070711e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648212836; 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=ij7jwhNxwyUGjai6WqTSYx+dGZAyzwqShnYRjOB6xKc=; b=V79rJczfu1VY2COmMzHemqJJ8NoKidSDpwIuTfDUH6jOQ8u1kbh6rTejVJSN2c/RhLtC2X zIYBmM8MXi5ytohv2xYChz33LPVkFavVxJAQcfCwit5VAG6UpQYnQKIFI4OBmm/KczZypB JwhlGXtlPtpvhWgeoM+pCF5VRmObbylkWG+RDs0XaLbKqRxZTV8/3KuPPB7iVyRDucy9o9 l57tUg3mws2ArImHI/q7GAQvFp/XLpbQPXeCVS6iDOi8EMAtMBMEbebLwjT/ABu3Jg2Okx b+0owKyl3AMPg8NPJqS8H/Xgj350eNxU7Pl1TR96/r3q2JaWARYQGtphOrZeTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648212836; a=rsa-sha256; cv=none; b=oHpxs3XSIYDEJG55IRO3H508ouKDCe845PIyEf1AkP9cwnRINN9wG+5x9B+Q1XmIVYoTGl HQtekiC9eF/fyea846/1ZHwwvjBFozDJNI5dYdLMfqox6/f0xrO9P5g+xcXagYgIjynH2a xGNdDPT35aDkvB0NzpRE/yI61oNkTfp81xW2NKMqAbZ0lEkTisY8wOqRFuPRPpn5g2ZEKN tbDZ06AWkbwQp7CwaCeYOJptqfiQOanXDGj9GumDc9RAVT3JMCxEG9Wkhxq5R+Pha37UyC sxPWPrspUWX2AtPlakrPKM9lG2lRlYzGYehY0fZmrg5AHrfAE+ZrSxDA10WyhQ== 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=3468cd95ca1249946bace931f2035e76b070711e commit 3468cd95ca1249946bace931f2035e76b070711e Author: Kristof Provost AuthorDate: 2022-03-25 10:13:47 +0000 Commit: Kristof Provost CommitDate: 2022-03-25 10:13:47 +0000 pf: ether l3 rules can only use addresses Disallow the use of tables in ethernet rules. Using tables requires taking the PF_RULES lock. Moreover, the current table code isn't ready to deal with ethernet rules. Disallow their use for now. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/parse.y | 10 ++++++++++ sys/netpfil/pf/pf_nv.c | 6 ++++++ tests/sys/netpfil/pf/ether.sh | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index bcbbfe872c6c..b3690fd22009 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -3261,6 +3261,16 @@ l3fromto : /* empty */ { bzero(&$$, sizeof($$)); } | L3 fromto { + if ($2.src.host != NULL && + $2.src.host->addr.type != PF_ADDR_ADDRMASK) { + yyerror("from must be an address"); + YYERROR; + } + if ($2.dst.host != NULL && + $2.dst.host->addr.type != PF_ADDR_ADDRMASK) { + yyerror("to must be an address"); + YYERROR; + } $$ = $2; } ; diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 3b0d92cc5d20..0a79dfb0de7a 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -1146,6 +1146,9 @@ pf_nveth_rule_to_keth_rule(const nvlist_t *nvl, nvlist_get_nvlist(nvl, "ipsrc"), &krule->ipsrc); if (error != 0) return (error); + + if (krule->ipsrc.addr.type != PF_ADDR_ADDRMASK) + return (EINVAL); } if (nvlist_exists_nvlist(nvl, "ipdst")) { @@ -1153,6 +1156,9 @@ pf_nveth_rule_to_keth_rule(const nvlist_t *nvl, nvlist_get_nvlist(nvl, "ipdst"), &krule->ipdst); if (error != 0) return (error); + + if (krule->ipdst.addr.type != PF_ADDR_ADDRMASK) + return (EINVAL); } PFNV_CHK(pf_nvstring(nvl, "qname", krule->qname, sizeof(krule->qname))); diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 319956219fe4..6e81f07ca26e 100644 --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -534,6 +534,11 @@ ip_body() "ether pass" \ "ether block out l3 to 192.0.2.3" atf_check -s exit:2 -o ignore ping -c 1 192.0.2.2 + + # We can't use tables in these rules + echo "ether pass out l3 from " | \ + atf_check -s exit:1 -o ignore -e ignore \ + jexec alcatraz pfctl -g -f - } ip_cleanup()