VirtualBox

Changeset 4824 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Sep 15, 2007 12:29:02 PM (17 years ago)
Author:
vboxsync
Message:

stricter checks.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDRVIOC.h

    r4811 r4824  
    5252# include <sys/ioccom.h>
    5353# define SUP_CTL_CODE_SIZE(Function, Size)      _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
    54 # define SUP_CTL_CODE_BIG(Function)             _IO(   'V', (Function) | SUP_IOCTL_FLAG)
     54# define SUP_CTL_CODE_BIG(Function)             _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
    5555# define SUP_CTL_CODE_FAST(Function)            _IO(   'V', (Function) | SUP_IOCTL_FLAG)
    5656# define SUP_CTL_CODE_NO_SIZE(uIOCtl)           (uIOCtl)
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r4811 r4824  
    494494}
    495495
     496
     497/** @def IOCPARM_LEN
     498 * Gets the length from the ioctl number.
     499 * This is normally defined by sys/ioccom.h on BSD systems...
     500 */
     501#ifndef IOCPARM_LEN
     502# define IOCPARM_LEN(x)     ( ((x) >> 16) & IOCPARM_MASK )
     503#endif
     504
     505
    496506/**
    497507 * Worker for VBoxSupDrvIOCtl that takes the slow IOCtl functions.
     
    515525     * Read the header.
    516526     */
     527    if (RT_UNLIKELY(IOC_PARMLEN(iCmd) != sizeof(Hdr)))
     528    {
     529        OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: iCmd=%#x len %d expected %d\n", iCmd, IOC_PARMLEN(iCmd), sizeof(Hdr)));
     530        return EINVAL;
     531    }
    517532    rc = ddi_copyin(&Hdr, (void *)iArg, sizeof(Hdr), Mode);
    518533    if (RT_UNLIKELY(rc))
    519534    {
    520         dprintf(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc));
     535        OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc));
    521536        return EFAULT;
    522537    }
    523538    if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
    524539    {
    525         dprintf(("VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd));
     540        OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd));
    526541        return EINVAL;
    527542    }
     543    cbBuf = RT_MAX(Hdr.cbIn, Hdr.cbOut);
     544    if (RT_UNLIKELY(    Hdr.cbIn < sizeof(Hdr)
     545                    ||  Hdr.cbOut < sizeof(Hdr)
     546                    ||  cbReq > _1M*16))
     547    {
     548        OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: max(%#x,%#x); iCmd=%#x\n", Hdr.cbIn, Hdr.cbOut, iCmd));
     549        return EINVAL;
     550    }
    528551
    529552    /*
    530553     * Buffer the request.
    531554     */
    532     cbBuf = RT_MAX(Hdr.cbIn, Hdr.cbOut);
    533     if (RT_UNLIKELY(cbBuf > _1M*16))
    534     {
    535         dprintf(("VBoxDrvSolarisIOCtlSlow: too big cbBuf=%#x; iCmd=%#x\n", cbBuf, iCmd));
    536         return E2BIG;
    537     }
    538     if (RT_UNLIKELY(cbBuf < sizeof(Hdr)))
    539     {
    540         dprintf(("VBoxDrvSolarisIOCtlSlow: bad ioctl cbBuf=%#x; iCmd=%#x.\n", cbBuf, iCmd));
    541         return EINVAL;
    542     }
    543     pHdr = RTMemAlloc(cbBuf);
     555    pHdr = RTMemTmpAlloc(cbBuf);
    544556    if (RT_UNLIKELY(!pHdr))
    545557    {
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