VirtualBox

Changeset 57904 in vbox


Ignore:
Timestamp:
Sep 25, 2015 7:57:12 PM (9 years ago)
Author:
vboxsync
Message:

VBoxNetFlt/darwin, VBoxNetAdp/darwin: Don't leak host-guest traffic to
the wire when the interface is in promiscuous mode. Call bpf_tap_in
and bpf_tap_out in the filter. Adjust VBoxNetAdp accordingly.

Location:
trunk/src/VBox/HostDrivers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp

    r57358 r57904  
    144144static errno_t vboxNetAdpDarwinOutput(ifnet_t pIface, mbuf_t pMBuf)
    145145{
    146     PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface);
    147     Assert(pThis);
    148     if (pThis->u.s.nTapMode & BPF_MODE_OUTPUT)
    149     {
    150         Log2(("vboxnetadp: out len=%d\n%.*Rhxd\n", mbuf_len(pMBuf), 14, mbuf_data(pMBuf)));
    151         bpf_tap_out(pIface, DLT_EN10MB, pMBuf, NULL, 0);
    152     }
     146    /*
     147     * We are a dummy interface with all the real work done in
     148     * VBoxNetFlt bridged networking filter.  If anything makes it
     149     * this far, just drop it, we have nowhere to send it to.
     150     */
    153151    mbuf_freem_list(pMBuf);
    154152    return 0;
     
    205203                                     protocol_family_t *pProtocolFamily)
    206204{
    207     PVBOXNETADP pThis = VBOXNETADP_FROM_IFACE(pIface);
    208     Assert(pThis);
    209     Log2(("vboxNetAdpDarwinDemux: mode=%d\n", pThis->u.s.nTapMode));
    210     if (pThis->u.s.nTapMode & BPF_MODE_INPUT)
    211     {
    212         Log2(("vboxnetadp: in len=%d\n%.*Rhxd\n", mbuf_len(pMBuf), 14, pFrameHeader));
    213         bpf_tap_in(pIface, DLT_EN10MB, pMBuf, pFrameHeader, ETHER_HDR_LEN);
    214     }
     205    /*
     206     * Anything we get here comes from VBoxNetFlt bridged networking
     207     * filter where it has already been accounted for and fed to bpf.
     208     */
    215209    return ether_demux(pIface, pMBuf, pFrameHeader, pProtocolFamily);
    216210}
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r57817 r57904  
    5959#include <net/if.h>
    6060#include <net/if_var.h>
     61RT_C_DECLS_BEGIN
     62#include <net/bpf.h>
     63RT_C_DECLS_END
    6164#include <netinet/in.h>
    6265#include <netinet/in_var.h>
     
    924927        {
    925928            /*
    926              * Check if this interface is in promiscuous mode. We should not drop
    927              * any packets before they get to the driver as it passes them to tap
    928              * callbacks in order for BPF to work properly.
     929             * If the interface is in promiscuous mode we should let
     930             * all inbound packets (this one was for a bridged guest)
     931             * reach the driver as it passes them to tap callbacks in
     932             * order for BPF to work properly.
    929933             */
    930             if (vboxNetFltDarwinIsPromiscuous(pThis))
     934            if (   fSrc == INTNETTRUNKDIR_WIRE
     935                && vboxNetFltDarwinIsPromiscuous(pThis))
     936            {
    931937                fDropIt = false;
     938            }
     939
     940            /*
     941             * A packet from the host to a guest.  As we won't pass it
     942             * to the drvier/wire we need to feed it to bpf ourselves.
     943             */
     944            if (fSrc == INTNETTRUNKDIR_HOST)
     945            {
     946                bpf_tap_out(pThis->u.s.pIfNet, DLT_EN10MB, pMBuf, NULL, 0);
     947            }
    932948        }
    933949    }
     
    10881104            Assert(pThis->pSwitchPort);
    10891105            pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
     1106#if 0
     1107            /*
     1108             * XXX: Don't tell SrvIntNetR0 if the interface is
     1109             * promiscuous, because there's no code yet to update that
     1110             * information and we don't want it stuck, spamming all
     1111             * traffic to the host.
     1112             */
    10901113            pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltDarwinIsPromiscuous(pThis));
     1114#endif
    10911115            pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0,  INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
    10921116            pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
     
    11271151        /*
    11281152         * Create a mbuf for the gather list and push it onto the wire.
    1129          *
    1130          * Note! If the interface is in the promiscuous mode we need to send the
    1131          *       packet down the stack so it reaches the driver and Berkeley
    1132          *       Packet Filter (see @bugref{5817}).
    11331153         */
    1134         if ((fDst & INTNETTRUNKDIR_WIRE) || vboxNetFltDarwinIsPromiscuous(pThis))
     1154        if (fDst & INTNETTRUNKDIR_WIRE)
    11351155        {
    11361156            mbuf_t pMBuf = vboxNetFltDarwinMBufFromSG(pThis, pSG);
     
    11531173            if (pMBuf)
    11541174            {
    1155                 /* This is what IONetworkInterface::inputPacket does. */
     1175                void *pvEthHdr = mbuf_data(pMBuf);
    11561176                unsigned const cbEthHdr = 14;
    1157                 mbuf_pkthdr_setheader(pMBuf, mbuf_data(pMBuf));
    1158                 mbuf_pkthdr_setlen(pMBuf, mbuf_pkthdr_len(pMBuf) - cbEthHdr);
    1159                 mbuf_setdata(pMBuf, (uint8_t *)mbuf_data(pMBuf) + cbEthHdr, mbuf_len(pMBuf) - cbEthHdr);
    1160                 mbuf_pkthdr_setrcvif(pMBuf, pIfNet); /* will crash without this. */
    1161 
     1177
     1178                mbuf_pkthdr_setrcvif(pMBuf, pIfNet);
     1179                mbuf_pkthdr_setheader(pMBuf, pvEthHdr); /* link-layer header */
     1180                mbuf_adj(pMBuf, cbEthHdr);              /* move to payload */
     1181
     1182                bpf_tap_in(pIfNet, DLT_EN10MB, pMBuf, pvEthHdr, cbEthHdr);
    11621183                errno_t err = ifnet_input(pIfNet, pMBuf, NULL);
    11631184                if (err)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette