Page MenuHomeFreeBSD

pf: protect the rpool from races
ClosedPublic

Authored by kp on Jan 13 2022, 10:06 AM.
Tags
None
Referenced Files
F167037293: D33874.id101408.diff
Tue, Aug 18, 5:03 PM
Unknown Object (File)
Mon, Aug 17, 2:23 PM
Unknown Object (File)
Sun, Aug 16, 7:36 PM
Unknown Object (File)
Sun, Aug 16, 7:20 PM
Unknown Object (File)
Fri, Aug 14, 9:52 PM
Unknown Object (File)
Fri, Aug 14, 8:38 PM
Unknown Object (File)
Thu, Aug 13, 8:28 PM
Unknown Object (File)
Thu, Aug 13, 11:08 AM

Details

Summary

The roundrobin pool stores its state in the rule, which could
potentially lead to invalid addresses being returned.

For example, thread A just executed PF_AINC(&rpool->counter) and
immediately afterwards thread B executes PF_ACPY(naddr, &rpool->counter)
(i.e. after the pf_match_addr() check of rpool->counter).

Lock the rpool with its own mutex to prevent these races. The
performance impact of this is expected to be low, as each rule has its
own lock, and the lock is also only relevant when state is being created
(so only for the initial packets of a connection, not for all traffic).

See also: https://redmine.pfsense.org/issues/12660
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 43897
Build 40785: arc lint + arc unit