diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2022-08-08 12:06:32 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2022-08-08 12:06:32 +0000 |
commit | 2c56b01a18fc4cacc0b9509a2657a57be470d69b (patch) | |
tree | ad5503da9e75dfee7b34906402bcfbcfa3249fad /sys/net/pf.c | |
parent | 8d515cf4247f32f44f2291ad4eb92432f69ee447 (diff) |
To make protocol input functions MP safe, internet PCB need protection.
Use their reference counter in more places.
The in_pcb lookup functions hold the PCBs in hash tables protected
by table->inpt_mtx mutex. Whenever a result is returned, increment
the ref count before releasing the mutex. Then the inp can be used
as long as neccessary. Unref it at the end of all functions that
call in_pcb lookup.
As a shortcut, pf may also hold a reference to the PCB. When
pf_inp_lookup() returns it, it also incements the ref count and the
caller can handle it like the inp from table lookup.
OK sashan@
Diffstat (limited to 'sys/net/pf.c')
-rw-r--r-- | sys/net/pf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c index 7183db91254..f23968f07c7 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.1136 2022/07/20 09:33:11 mbuhl Exp $ */ +/* $OpenBSD: pf.c,v 1.1137 2022/08/08 12:06:30 bluhm Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -3375,6 +3375,7 @@ pf_socket_lookup(struct pf_pdesc *pd) pd->lookup.uid = inp->inp_socket->so_euid; pd->lookup.gid = inp->inp_socket->so_egid; pd->lookup.pid = inp->inp_socket->so_cpid; + in_pcbunref(inp); return (1); } @@ -7531,6 +7532,7 @@ pf_inp_lookup(struct mbuf *m) if (inp && inp->inp_pf_sk) KASSERT(m->m_pkthdr.pf.statekey == inp->inp_pf_sk); + in_pcbref(inp); return (inp); } |