diff options
author | 2004-12-26 05:58:25 +0000 | |
---|---|---|
committer | 2004-12-26 05:58:25 +0000 | |
commit | 3dfee61500f341a9be47762a95c6e3078016267d (patch) | |
tree | 0f347a49d3ccb9860d976a8144cd3ba66d206429 | |
parent | htole32 and friends to get this working on big endian (macppc) (diff) | |
download | wireguard-openbsd-3dfee61500f341a9be47762a95c6e3078016267d.tar.xz wireguard-openbsd-3dfee61500f341a9be47762a95c6e3078016267d.zip |
Bounce the mbuf to the BPF listener before committing it to the wire
in the TX case, fixes rare problems associated with accessing already
free'd memory if the encap routine bails out (panic in PROMISC mode).
ok deraadt
-rw-r--r-- | sys/dev/pci/if_vge.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c index 9eaffa2c725..69ee6d831ea 100644 --- a/sys/dev/pci/if_vge.c +++ b/sys/dev/pci/if_vge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vge.c,v 1.3 2004/12/26 05:54:30 pvalchev Exp $ */ +/* $OpenBSD: if_vge.c,v 1.4 2004/12/26 05:58:25 pvalchev Exp $ */ /* $FreeBSD: if_vge.c,v 1.3 2004/09/11 22:13:25 wpaul Exp $ */ /* * Copyright (c) 2004 @@ -1445,10 +1445,18 @@ vge_start(struct ifnet *ifp) while (sc->vge_ldata.vge_tx_mbuf[idx] == NULL) { IF_DEQUEUE(&ifp->if_snd, m_head); - if (m_head == NULL) break; + /* + * If there's a BPF listener, bounce a copy of this frame + * to him. + */ +#if NBPFILTER > 0 + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m_head); +#endif + if (vge_encap(sc, m_head, idx)) { IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; @@ -1460,15 +1468,6 @@ vge_start(struct ifnet *ifp) pidx = idx; VGE_TX_DESC_INC(idx); - - /* - * If there's a BPF listener, bounce a copy of this frame - * to him. - */ -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head); -#endif } if (idx == sc->vge_ldata.vge_tx_prodidx) { |