summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2018-06-04 12:22:45 +0000
committerbluhm <bluhm@openbsd.org>2018-06-04 12:22:45 +0000
commit3f2d79b34bf6dece8c350a5a4bee9f674713b8dc (patch)
tree49fd1da580f91377a3121235c0cd04af9a9e2655 /sys
parenttweak the text of the relaying example: make it clear that the example (diff)
downloadwireguard-openbsd-3f2d79b34bf6dece8c350a5a4bee9f674713b8dc.tar.xz
wireguard-openbsd-3f2d79b34bf6dece8c350a5a4bee9f674713b8dc.zip
The function pf_create_state() calls pf_set_protostate() before
pf_state_insert(), so the state key has not been set. When inlining, the compiler recognized the NULL pointer dereference in s->key[PF_SK_STACK]->proto and optimized it away. But if pf.c was compiled with -fno-inline, the system crashed during boot. Add a NULL check in pf_set_protostate() to handle the situation when the function is called. OK sashan@ henning@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/pf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c
index 8d791b8c7e6..fc6fce33716 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.1066 2018/06/01 12:38:25 bluhm Exp $ */
+/* $OpenBSD: pf.c,v 1.1067 2018/06/04 12:22:45 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -400,7 +400,8 @@ pf_set_protostate(struct pf_state *s, int which, u_int8_t newstate)
if (s->src.state == newstate)
return;
- if (s->key[PF_SK_STACK]->proto == IPPROTO_TCP &&
+ if (s->key[PF_SK_STACK] != NULL &&
+ s->key[PF_SK_STACK]->proto == IPPROTO_TCP &&
!(TCPS_HAVEESTABLISHED(s->src.state) ||
s->src.state == TCPS_CLOSED) &&
(TCPS_HAVEESTABLISHED(newstate) || newstate == TCPS_CLOSED))