aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-06-28 18:29:58 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-06-29 07:24:52 +0000
commit7f025db57c7879bfa43ac74ecd95903439fdd1d0 (patch)
tree51b2f69de0dacffdd33eda298e495dc714cf4082
parentb33d1898c1b0e6d76b52eb48078260588802dc95 (diff)
downloadsrc-7f025db57c7879bfa43ac74ecd95903439fdd1d0.tar.gz
src-7f025db57c7879bfa43ac74ecd95903439fdd1d0.zip
pf: fix error-case leaks in pf_create_state
The hand-rolled clean up failed to free counters. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--sys/netpfil/pf/pf.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 26989adfb613..f05dc69b3dbb 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -3827,7 +3827,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
REASON_SET(&reason, PFRES_MAPFAILED);
pf_src_tree_remove_state(s);
STATE_DEC_COUNTERS(s);
- uma_zfree(V_pf_state_z, s);
+ pf_free_state(s);
goto csfailed;
}
s->rt_kif = r->rpool.cur->kif;
@@ -3849,7 +3849,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
REASON_SET(&reason, PFRES_MEMORY);
pf_src_tree_remove_state(s);
STATE_DEC_COUNTERS(s);
- uma_zfree(V_pf_state_z, s);
+ pf_free_state(s);
return (PF_DROP);
}
if ((pd->flags & PFDESC_TCP_NORM) && s->src.scrub &&
@@ -3859,10 +3859,9 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
DPFPRINTF(PF_DEBUG_URGENT,
("pf_normalize_tcp_stateful failed on first "
"pkt\n"));
- pf_normalize_tcp_cleanup(s);
pf_src_tree_remove_state(s);
STATE_DEC_COUNTERS(s);
- uma_zfree(V_pf_state_z, s);
+ pf_free_state(s);
return (PF_DROP);
}
}
@@ -3886,12 +3885,10 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
if (pf_state_insert(BOUND_IFACE(r, kif), kif,
(pd->dir == PF_IN) ? sk : nk,
(pd->dir == PF_IN) ? nk : sk, s)) {
- if (pd->proto == IPPROTO_TCP)
- pf_normalize_tcp_cleanup(s);
REASON_SET(&reason, PFRES_STATEINS);
pf_src_tree_remove_state(s);
STATE_DEC_COUNTERS(s);
- uma_zfree(V_pf_state_z, s);
+ pf_free_state(s);
return (PF_DROP);
} else
*sm = s;