HomeFreeBSD

pf: release rules lock before passing the packet to dummynet

Description

pf: release rules lock before passing the packet to dummynet

In the Ethernet rules we held the PF_RULES lock while we called
ip_dn_io_ptr() (i.e. dummynet). That meant that we could end up back in
pf while still holding the PF_RULES lock.
That's not immediately fatal, because that lock is recursive, but still
not ideal.

There also appear to be scenarios where this can actually trigger
deadlocks.

We don't need to hold the PF_RULES lock, as long as we make a local copy
of the data we need from the rule (in this case, the action and
bridge_to target). It's safe to keep the struct ifnet pointer around,
because we remain in NET_EPOCH.

See also: https://redmine.pfsense.org/issues/14373
MFC after: 1 week
Reviewed by: mjg
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D40067

Details

Provenance
kpAuthored on May 11 2023, 4:10 PM
Reviewer
mjg
Differential Revision
D40067: pf: release rules lock before passing the packet to dummynet
Parents
rG37c1ef5ac0a2: Move the arm64 sigcode to .rodata
Branches
Unknown
Tags
Unknown