Page MenuHomeFreeBSD

pf: protect the rpool from races
ClosedPublic

Authored by kp on Jan 13 2022, 10:06 AM.
Tags
None
Referenced Files
F107115802: D33874.id101453.diff
Fri, Jan 10, 8:49 AM
Unknown Object (File)
Dec 2 2024, 10:54 AM
Unknown Object (File)
Oct 14 2024, 11:05 PM
Unknown Object (File)
Oct 10 2024, 8:17 AM
Unknown Object (File)
Oct 9 2024, 4:23 AM
Unknown Object (File)
Oct 6 2024, 6:02 PM
Unknown Object (File)
Oct 5 2024, 2:25 AM
Unknown Object (File)
Oct 3 2024, 8:24 PM

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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable