git: c556863aad24 - main - pf: fully free rule on error
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Nov 2026 18:11:54 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c556863aad24b793726b71995826e9f86c3178cd
commit c556863aad24b793726b71995826e9f86c3178cd
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-11-20 14:25:50 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-23 17:17:12 +0000
pf: fully free rule on error
In pf_ioctl_addrule() we freed the rule with pf_krule_free() rather than
pf_free_rule() so not everything (e.g. kif, table, dynaddr) got freed.
As pf_free_rule() expects to be called with the rules lock held we only
use it after we've actually locked. We continue to free the rule with
pf_krule_free() if we error out prior to acquiring the lock. This is safe
because we don't set up any of the things we need pf_krule_free() to
clean up for us until after we take the lock.
Reported by: Kevin Day <kevin@your.org>
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
sys/netpfil/pf/pf_ioctl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index f6baa248722c..9d45145f6f63 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -3213,6 +3213,8 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket,
#undef ERROUT
#undef ERROUT_UNLOCKED
errout:
+ pf_free_rule(rule);
+ rule = NULL;
PF_RULES_WUNLOCK();
PF_CONFIG_UNLOCK();
errout_unlocked: