Bug 296554 - pfctl no longer can open /dev/pf in read only mode
Summary: pfctl no longer can open /dev/pf in read only mode
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-pf (Nobody)
URL:
Keywords: regression
Depends on: 291981
Blocks:
  Show dependency treegraph
 
Reported: 2026-07-06 15:15 UTC by Jim Pirzyk
Modified: 2026-07-06 17:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Pirzyk freebsd_committer freebsd_triage 2026-07-06 15:15:03 UTC
After an upgrade from FreeBSD 14.4-RELEASE-p7 to 15.1-RELEASE-p1 I found that the command:

pfctl -T show -t f2b

no longer works as a member of the network group.  I have tweaked the device /dev/pf permission to be 640 root:network and the user running it is in the network group.

ktrace shows that the device is being opened RDONLY mode in 14.4 and RDWR mode in 15.1

14.4:

 64017 pfctl    CALL  openat(AT_FDCWD,0x1d14f5962104,0<O_RDONLY>)
 64017 pfctl    NAMI  "/dev/pf"

15.1:

  8223 pfctl    CALL  openat(AT_FDCWD,0x52808cc779e,0x2<O_RDWR>)
  8223 pfctl    NAMI  "/dev/pf"

There is code in pfctl to determine what commands are being run and use the RDONLY when applicable:

        if (tblcmdopt != NULL) {
                argc -= optind;
                argv += optind;
                ch = *tblcmdopt;
                if (ch == 'l') {
                        loadopt |= PFCTL_FLAG_TABLE;
                        tblcmdopt = NULL;
                } else
                        mode = strchr("st", ch) ? O_RDONLY : O_RDWR;

This mode variable is being ignore by pfctl_open() call:

        pfh = pfctl_open(pf_device);
        if (pfh == NULL)
                err(1, "Failed to open netlink");

and I believe this is due to the conversion to netlink and is the same root cause as Bug 294871

I thought it was useful to show another case where moving to netlink has broken existing functionality.
Comment 1 Jim Pirzyk freebsd_committer freebsd_triage 2026-07-06 15:19:58 UTC
In the initial submission, I referenced the wrong Bug ID, it should be 291981