VirtualBox

Ignore:
Timestamp:
Mar 24, 2011 6:15:17 AM (14 years ago)
Author:
vboxsync
Message:

VBoxNetFlt/FreeBSD: Fix kernel crash if VIMAGE is enabled (Thanks to Mikolaj Golub and Bernhard Froehlich)

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk

    r36121 r36385  
    425425                $$(if $$(eq $$(VBoxNetFlt/freebsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
    426426                | $$(dir $$@)
     427        $(QUIET)$(CP) -f $< $@
    427428 ifndef VBOX_WITH_HARDENING
    428         $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
    429  else
    430         $(QUIET)$(CP) -f $< $@
     429        $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output [email protected] $@
     430        ${QUIET}$(MV) -f [email protected] $@
     431 endif
     432 ifndef VBOX_WITH_NETFLT_VIMAGE
     433        $(QUIET)$(SED) -e "s;-DVIMAGE;;g" --output [email protected] $@
     434        ${QUIET}$(MV) -f [email protected] $@
    431435 endif
    432436endif # freebsd
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/Makefile

    r28800 r36385  
    1919KMOD = vboxnetflt
    2020
    21 CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING
     21CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE
    2222
    2323.if (${MACHINE_ARCH} == "i386")
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c

    r30111 r36385  
    9898#define PACKET_TAG_VBOX        128
    9999
     100#if defined(__FreeBSD_version) && __FreeBSD_version >= 800500
     101# include <sys/jail.h>
     102# include <net/vnet.h>
     103
     104# define VBOXCURVNET_SET(arg)           CURVNET_SET_QUIET(arg)
     105# define VBOXCURVNET_SET_FROM_UCRED()   VBOXCURVNET_SET(CRED_TO_VNET(curthread->td_ucred))
     106# define VBOXCURVNET_RESTORE()          CURVNET_RESTORE()
     107
     108#else /* !defined(__FreeBSD_version) || __FreeBSD_version < 800500 */
     109
     110# define VBOXCURVNET_SET(arg)
     111# define VBOXCURVNET_SET_FROM_UCRED()
     112# define VBOXCURVNET_RESTORE()
     113
     114#endif /* !defined(__FreeBSD_version) || __FreeBSD_version < 800500 */
     115
    100116/*
    101117 * Netgraph command list, we don't support any
     
    323339    bool fActive;
    324340
     341    VBOXCURVNET_SET(ifp->if_vnet);
    325342    fActive = vboxNetFltTryRetainBusyActive(pThis);
    326343
     
    347364            if (fActive)
    348365                vboxNetFltRelease(pThis, true /*fBusy*/);
     366            VBOXCURVNET_RESTORE();
    349367            return (0);
    350368        }
     
    364382            if (fActive)
    365383                vboxNetFltRelease(pThis, true /*fBusy*/);
     384            VBOXCURVNET_RESTORE();
    366385            return rc;
    367386        }
     
    378397    if (fActive)
    379398        vboxNetFltRelease(pThis, true /*fBusy*/);
     399    VBOXCURVNET_RESTORE();
    380400    return (0);
    381401}
     
    410430    PINTNETSG pSG;
    411431
     432    VBOXCURVNET_SET(ifp->if_vnet);
    412433    vboxNetFltRetain(pThis, true /* fBusy */);
    413434    for (;;)
     
    439460    }
    440461    vboxNetFltRelease(pThis, true /* fBusy */);
     462    VBOXCURVNET_RESTORE();
    441463}
    442464
     
    453475    PINTNETSG pSG;
    454476
     477    VBOXCURVNET_SET(ifp->if_vnet);
    455478    vboxNetFltRetain(pThis, true /* fBusy */);
    456479    for (;;)
     
    482505    }
    483506    vboxNetFltRelease(pThis, true /* fBusy */);
     507    VBOXCURVNET_RESTORE();
    484508}
    485509
     
    499523
    500524    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
     525    VBOXCURVNET_SET(ifp->if_vnet);
    501526
    502527    if (fDst & INTNETTRUNKDIR_WIRE)
     
    540565        ifp->if_input(ifp, m);
    541566    }
     567    VBOXCURVNET_RESTORE();
    542568    return VINF_SUCCESS;
    543569}
     
    557583    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    558584
     585    VBOXCURVNET_SET_FROM_UCRED();
    559586    NOREF(pvContext);
    560587    ifp = ifunit(pThis->szName);
     
    603630        vboxNetFltRelease(pThis, true /*fBusy*/);
    604631    }
     632    VBOXCURVNET_RESTORE();
    605633
    606634    return VINF_SUCCESS;
     
    612640
    613641    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
     642    VBOXCURVNET_SET(ifp->if_vnet);
    614643    /*
    615644     * Attempt to check if the interface is still there and re-initialize if
     
    629658        vboxNetFltOsInitInstance(pThis, NULL);
    630659    }
     660    VBOXCURVNET_RESTORE();
    631661
    632662    return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost);
     
    670700
    671701    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
     702    VBOXCURVNET_SET(ifp->if_vnet);
    672703    node = ASMAtomicUoReadPtrT(&pThis->u.s.node, node_p);
    673704
     
    743774        NG_SEND_MSG_PATH(error, node, msg, path, 0);
    744775    }
     776    VBOXCURVNET_RESTORE();
    745777}
    746778
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