git: 96c545176df7 - main - pf: don't allow any ioctl calls until we're fully initialised

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 24 Nov 2026 12:53:36 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=96c545176df7be2c33587fe4a35ac18af40d8dea

commit 96c545176df7be2c33587fe4a35ac18af40d8dea
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-11-24 09:58:25 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-24 10:48:34 +0000

    pf: don't allow any ioctl calls until we're fully initialised
    
    We create the /dev/pf node before we're fully initialised, leaving a
    (very small) gap where ioctl calls could be made before we're ready
    for them.
    
    PR:             301074
    MFC after:      2 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf_ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 9d45145f6f63..297be51a58b5 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -4173,6 +4173,10 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td
 
 	CURVNET_SET(TD_TO_VNET(td));
 
+	/* Don't allow ioctl calls until we're fully initialised. */
+	if (V_pf_vnet_active == 0)
+		return (EBUSY);
+
 	switch (cmd) {
 #ifdef COMPAT_FREEBSD14
 	case DIOCSTART: