pf: fix sctp deadlock

It is possible for pf_test_state_sctp() to find a state and still return
PF_DROP (or not PF_PASS, to be exact). In that case we would run pf_test_rule()
unconditionally, but this would overwrite the (locked!) state pointer
pf_test_state_sctp() gave us. As a result we will later deadlock, trying the
lock the already locked state.

Do what we do for UDP and TCP, and explicitly check s for NULL before we run
pf_test_rule().

MFC after:	1 week
Sponsored by:	Orange Business Services
This commit is contained in:
Kristof Provost 2024-07-09 20:49:49 +02:00
parent 43a62df0b4
commit a9639adaed

View File

@ -8269,7 +8269,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0,
V_pfsync_update_state_ptr(s);
r = s->rule.ptr;
a = s->anchor.ptr;
} else {
} else if (s == NULL) {
action = pf_test_rule(&r, &s, kif, m, off,
&pd, &a, &ruleset, inp);
}
@ -8895,7 +8895,7 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb
V_pfsync_update_state_ptr(s);
r = s->rule.ptr;
a = s->anchor.ptr;
} else {
} else if (s == NULL) {
action = pf_test_rule(&r, &s, kif, m, off,
&pd, &a, &ruleset, inp);
}