Page MenuHomeFreeBSD

pfsync: Do not reference the tag of an imported state
Needs ReviewPublic

Authored by rcm on Fri, Oct 9, 4:54 PM.
Tags
None
Referenced Files
F175872155: D60537.diff
Wed, Oct 14, 2:03 AM
Unknown Object (File)
Tue, Oct 13, 2:21 PM
Unknown Object (File)
Mon, Oct 12, 3:03 PM
Unknown Object (File)
Mon, Oct 12, 2:57 PM
Unknown Object (File)
Sun, Oct 11, 6:31 PM
Unknown Object (File)
Sun, Oct 11, 6:18 PM
Unknown Object (File)
Sun, Oct 11, 10:53 AM
Unknown Object (File)
Sat, Oct 10, 11:56 PM

Details

Reviewers
kp
Summary

pfsync_state_import() looks up the tag of a version 1500 state with
pf_tagname2tag(), which takes a reference on the tag and creates it
when no rule uses the name. States do not hold a reference on their
tag, so nothing releases this one: every imported state adds a
reference, and the tag stays allocated after the last rule that uses
it is gone.

Look the tag up without taking a reference, as a state created by a
rule has it. A name that no rule uses is no longer created; nothing
could match it, and the state is imported without a tag.

Fixes: 99475087d63b ("pf: Add pfsync protocol for FreeBSD 15")
MFC after: 1 week
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:54 PM
kp added inline comments.
sys/netpfil/pf/pf_ioctl.c
843

Should we be implementing this as a call to tagname2tag() with an extra argument to tell it not to take a ref?

This revision is now accepted and ready to land.Tue, Oct 13, 2:19 PM
rcm edited the summary of this revision. (Show Details)

Use the existing add_new argument of tagname2tag() instead of a separate lookup: it now also skips the reference and drops the printf. pf_tagname2tag() takes the flag directly, like pf_qname2qid().

This revision now requires review to proceed.Tue, Oct 13, 4:55 PM
rcm marked an inline comment as done.