Page MenuHomeFreeBSD

pf: Free unreferenced interfaces after dropping pfi_unlnkdkifs_mtx
Needs ReviewPublic

Authored by rcm on Fri, Oct 9, 4:09 PM.
Tags
None
Referenced Files
F175566783: D60535.id.diff
Sun, Oct 11, 6:18 PM
F175501378: D60535.diff
Sun, Oct 11, 7:13 AM
F175501335: D60535.id189259.diff
Sun, Oct 11, 7:12 AM
Unknown Object (File)
Sun, Oct 11, 6:40 AM
Unknown Object (File)
Sun, Oct 11, 5:16 AM
Unknown Object (File)
Sat, Oct 10, 4:49 PM
Unknown Object (File)
Sat, Oct 10, 4:44 PM
Unknown Object (File)
Sat, Oct 10, 3:19 PM

Details

Reviewers
kp
mjg
Summary

On 32-bit arm pf_kkif_free() takes the rules lock to unlink the
interface from the list of counters to update, and pfi_kkif_purge()
called it with pfi_unlnkdkifs_mtx held. pfi_kkif_remove_if_unref()
takes the two in the other order: the rules lock first, as asserted,
and pfi_unlnkdkifs_mtx to put the interface on the list.

Move the interfaces to free to a local list under the mutex and
free them after it is released.

Fixes: d40d4b3ed788 ("pf: switch kif counters to pf_counter_u64")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rcm requested review of this revision.Fri, Oct 9, 4:09 PM
sys/netpfil/pf/pf_if.c
472

this shold be LIST_FOREACH_SAFE

sys/netpfil/pf/pf_if.c
459

this should be LIST_FOREACH now

rcm marked 2 inline comments as done.Fri, Oct 9, 5:49 PM
rcm added inline comments.
sys/netpfil/pf/pf_if.c
459

I believe this has to stay _SAFE. The loop moves kif to freeq, which rewrites kif->pfik_list.le_next, so plain LIST_FOREACH would follow that into freeq.

472

Ah yes thanks

rcm marked 2 inline comments as done.
sys/netpfil/pf/pf_if.c
459

oof, i somehow discounted LIST_REMOVE. yes indeed this line should stay as it is

rcm marked an inline comment as done.Fri, Oct 9, 5:52 PM