diff options
author | 2015-03-03 11:14:00 +0000 | |
---|---|---|
committer | 2015-03-03 11:14:00 +0000 | |
commit | 207deb981516a29e9877975a2a1f35005a24c3e9 (patch) | |
tree | a9f5bec99ac9b073fd49c5713881529f0e9c806d | |
parent | regen (diff) | |
download | wireguard-openbsd-207deb981516a29e9877975a2a1f35005a24c3e9.tar.xz wireguard-openbsd-207deb981516a29e9877975a2a1f35005a24c3e9.zip |
make sure hfsc_attach, hfsc_detach, hfsc_addqueue, hfsc_delqueue and
hfsc_qstats cope with a NULL ifp. Can happen when refering to nonexistant
interfaces from pf.conf. Problem noticed and fix tested by Kevin Chadwick
<ma1l1ists at yahoo.co.uk>, ok phessler benno
-rw-r--r-- | sys/net/hfsc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c index 4d32e174b76..4036fe44db7 100644 --- a/sys/net/hfsc.c +++ b/sys/net/hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hfsc.c,v 1.15 2015/02/08 03:16:16 henning Exp $ */ +/* $OpenBSD: hfsc.c,v 1.16 2015/03/03 11:14:00 henning Exp $ */ /* * Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org> @@ -163,7 +163,7 @@ hfsc_attach(struct ifnet *ifp) tblsize = HFSC_DEFAULT_CLASSES * sizeof(void *); - if (ifp->if_snd.ifq_hfsc != NULL) + if (ifp == NULL || ifp->if_snd.ifq_hfsc != NULL) return (0); hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK | M_ZERO); @@ -184,8 +184,12 @@ hfsc_attach(struct ifnet *ifp) int hfsc_detach(struct ifnet *ifp) { - struct hfsc_if *hif = ifp->if_snd.ifq_hfsc; + struct hfsc_if *hif; + + if (ifp == NULL) + return (0); + hif = ifp->if_snd.ifq_hfsc; timeout_del(&hif->hif_defer); ifp->if_snd.ifq_hfsc = NULL; @@ -203,6 +207,9 @@ hfsc_addqueue(struct pf_queuespec *q) struct hfsc_class *cl, *parent; struct hfsc_sc rtsc, lssc, ulsc; + if (q->kif->pfik_ifp == NULL) + return (0); + if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL) return (EINVAL); @@ -242,6 +249,9 @@ hfsc_delqueue(struct pf_queuespec *q) struct hfsc_if *hif; struct hfsc_class *cl; + if (q->kif->pfik_ifp == NULL) + return (0); + if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL) return (EINVAL); @@ -259,6 +269,9 @@ hfsc_qstats(struct pf_queuespec *q, void *ubuf, int *nbytes) struct hfsc_class_stats stats; int error = 0; + if (q->kif->pfik_ifp == NULL) + return (EBADF); + if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL) return (EBADF); |