From: Roy Marples Date: Mon, 28 Sep 2020 20:10:21 +0000 (+0100) Subject: privsep: fix crash when interface departs before bpf returns for it X-Git-Tag: v9.3.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c35a09f0dffba170cb46323b66fce92e2b47256f;p=thirdparty%2Fdhcpcd.git privsep: fix crash when interface departs before bpf returns for it --- diff --git a/src/dhcp.c b/src/dhcp.c index 61cc256a..923c5af5 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -3477,6 +3477,9 @@ dhcp_packet(struct interface *ifp, uint8_t *data, size_t len, #ifdef PRIVSEP const struct dhcp_state *state = D_CSTATE(ifp); + if (state == NULL) + return; + /* Ignore double reads */ if (IN_PRIVSEP(ifp->ctx)) { switch (state->state) { diff --git a/src/privsep-bpf.c b/src/privsep-bpf.c index f7662333..f8240f12 100644 --- a/src/privsep-bpf.c +++ b/src/privsep-bpf.c @@ -266,6 +266,10 @@ ps_bpf_dispatch(struct dhcpcd_ctx *ctx, size_t bpf_len; ifp = if_findindex(ctx->ifaces, psm->ps_id.psi_ifindex); + /* interface may have departed .... */ + if (ifp == NULL) + return -1; + bpf = iov->iov_base; bpf_len = iov->iov_len;