From 55f031f303b17cab69cc04ae4f7a06bac4b71885 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Sun, 22 Mar 2026 03:50:47 +0100 Subject: [PATCH] pfctl: parser must not ignore error from pfctl_optimize_ruleset() Ignoring the error may cause pfctl(8) to load inconsistent ruleset preventing pf(4) to enforce desired policy. Issue reported and fix suggested by berts _from_ fastmail _dot_ com 'Looks good.' @deraadt MFC after: 1 week Obtained from: OpenBSD, sashan , 9fd28a8cca Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 343ace42f82a629374af4dc3a72da5f46f2c3feb) --- sbin/pfctl/pfctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 518b3208556..50ed978d1a7 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1959,8 +1959,9 @@ pfctl_load_ruleset(struct pfctl *pf, char *path, struct pfctl_ruleset *rs, } - if (pf->optimize && rs_num == PF_RULESET_FILTER) - pfctl_optimize_ruleset(pf, rs); + if (pf->optimize && rs_num == PF_RULESET_FILTER && + (error = pfctl_optimize_ruleset(pf, rs)) != 0) + goto error; while ((r = TAILQ_FIRST(rs->rules[rs_num].active.ptr)) != NULL) { TAILQ_REMOVE(rs->rules[rs_num].active.ptr, r, entries);