HomeFreeBSD

pf: improve pf_state_key_attach() error handling

Description

pf: improve pf_state_key_attach() error handling

If we fail to attach the stack key that means we've already attached the wire
key. That means the state could be found by other cores, and given that we then
free it, be used after free.
Fix this by not releasing the ID hashrow lock and key locks until after we've
removed the inserted key again, ensuring the state cannot be found by other
cores.

Reported by: markj
Submitted by: glebius
Reviewed by: glebius, markj
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D49550

(cherry picked from commit 8efd2acf07bc0e1c3ea1f7390e0f1cfb7cf6f86c)

Details

Provenance
kpAuthored on Mar 27 2025, 2:21 PM
Reviewer
glebius
Differential Revision
D49550: pf: improve pf_state_key_attach() error handling
Parents
rGc6cb1b2ee506: cp: Improve error messages.
Branches
Unknown
Tags
Unknown