git: b89bc49a6348 - stable/14 - pf: explicitly NULL state key pointers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Apr 2025 21:15:45 UTC
The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b89bc49a63483bdb0617c2fcebeb2faf2565e994 commit b89bc49a63483bdb0617c2fcebeb2faf2565e994 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-03-27 14:37:59 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-04-21 20:25:46 +0000 pf: explicitly NULL state key pointers After the pf_state_insert() call we may not use these pointers again. Explicitly NULL them to ensure we don't. Also NULL them out if we free the keys directly. Reviewed by: glebius, markj MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D49553 (cherry picked from commit 592418343348bcf4355c249f53cff89ed90ea1f5) --- sys/netpfil/pf/pf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index c74d2f5efadb..8201d3e24db7 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1629,6 +1629,7 @@ pf_state_insert(struct pfi_kkif *kif, struct pfi_kkif *orig_kif, /* Returns with ID locked on success. */ if ((error = pf_state_key_attach(skw, sks, s)) != 0) return (error); + skw = sks = NULL; ih = &V_pf_idhash[PF_IDHASH(s)]; PF_HASHROW_ASSERT(ih); @@ -5064,6 +5065,7 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, struct pfi_kkif *kif, action = pf_create_state(r, nr, a, pd, nsn, nk, sk, m, off, sport, dport, &rewrite, kif, sm, tag, bproto_sum, bip_sum, hdrlen, &match_rules); + sk = nk = NULL; if (action != PF_PASS) { pd->act.log |= PF_LOG_FORCE; if (action == PF_DROP && @@ -5081,6 +5083,7 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, struct pfi_kkif *kif, uma_zfree(V_pf_state_key_z, sk); uma_zfree(V_pf_state_key_z, nk); + sk = nk = NULL; } /* copy back packet headers if we performed NAT operations */ @@ -5294,6 +5297,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, goto drop; } else *sm = s; + sk = nk = NULL; if (tag > 0) s->tag = tag;