diff options
author | Alexandr Nedvedicky <sashan@cvs.openbsd.org> | 2019-08-29 06:13:47 +0000 |
---|---|---|
committer | Alexandr Nedvedicky <sashan@cvs.openbsd.org> | 2019-08-29 06:13:47 +0000 |
commit | ad61e3a01adefb36862036985b37f9bee2c1ef33 (patch) | |
tree | 4ace49263517b517f165bd490192f4413330b4cc /sys/net | |
parent | 2add8086ddc31a42a1eab9a088ec2b67a6930511 (diff) |
pf_state_insert() must grab state lock exclusively
ok bluhm@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/pf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c index 38f87e19ce6..53205e0e6b1 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.1088 2019/08/26 09:19:12 sashan Exp $ */ +/* $OpenBSD: pf.c,v 1.1089 2019/08/29 06:13:46 sashan Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -948,19 +948,24 @@ pf_state_insert(struct pfi_kif *kif, struct pf_state_key **skw, PF_ASSERT_LOCKED(); s->kif = kif; + PF_STATE_ENTER_WRITE(); if (*skw == *sks) { - if (pf_state_key_attach(*skw, s, PF_SK_WIRE)) + if (pf_state_key_attach(*skw, s, PF_SK_WIRE)) { + PF_STATE_EXIT_WRITE(); return (-1); + } *skw = *sks = s->key[PF_SK_WIRE]; s->key[PF_SK_STACK] = s->key[PF_SK_WIRE]; } else { if (pf_state_key_attach(*skw, s, PF_SK_WIRE)) { pool_put(&pf_state_key_pl, *sks); + PF_STATE_EXIT_WRITE(); return (-1); } *skw = s->key[PF_SK_WIRE]; if (pf_state_key_attach(*sks, s, PF_SK_STACK)) { pf_state_key_detach(s, PF_SK_WIRE); + PF_STATE_EXIT_WRITE(); return (-1); } *sks = s->key[PF_SK_STACK]; @@ -978,12 +983,14 @@ pf_state_insert(struct pfi_kif *kif, struct pf_state_key **skw, addlog("\n"); } pf_detach_state(s); + PF_STATE_EXIT_WRITE(); return (-1); } TAILQ_INSERT_TAIL(&state_list, s, entry_list); pf_status.fcounters[FCNT_STATE_INSERT]++; pf_status.states++; pfi_kif_ref(kif, PFI_KIF_REF_STATE); + PF_STATE_EXIT_WRITE(); #if NPFSYNC > 0 pfsync_insert_state(s); #endif /* NPFSYNC > 0 */ |