Page MenuHomeFreeBSD

pf: fix udp_mapping cleanup
ClosedPublic

Authored by kp on Nov 13 2025, 3:23 PM.
Tags
None
Referenced Files
F171900076: D53737.id166576.diff
Mon, Sep 14, 10:59 AM
Unknown Object (File)
Fri, Sep 11, 12:10 AM
Unknown Object (File)
Thu, Sep 10, 11:49 PM
Unknown Object (File)
Mon, Aug 31, 6:11 PM
Unknown Object (File)
Mon, Aug 31, 11:39 AM
Unknown Object (File)
Fri, Aug 28, 6:16 PM
Unknown Object (File)
Thu, Aug 27, 10:52 PM
Unknown Object (File)
Wed, Aug 26, 12:46 PM

Details

Summary

If we fail to obtain a new source port (pf_get_sport()) while we've
created a udp_mapping (for 'endpoint independent nat') we must free the
udp_mapping in pf_get_sport(). Otherwise the calling function will call
pf_udp_mapping_release(). This will then attempt to remove the udp_mapping from
a list it's not in, and crash.

Actually free the udp_mapping in all failure cases. While here sprinkle in a few
more assertions to ensure we don't forget leak udp_mappings and add a test case
to provoke this problem.

MFC after: 1 week
See also: https://redmine.pfsense.org/issues/16517
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable