Changeset 52575 in vbox
- Timestamp:
- Sep 3, 2014 7:36:27 AM (10 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r52192 r52575 2293 2293 * @param pReqHdr The request header. 2294 2294 */ 2295 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr )2295 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq) 2296 2296 { 2297 2297 int rc; … … 2301 2301 * Validate the request. 2302 2302 */ 2303 /* this first check could probably be omitted as its also done by the OS specific code... */ 2303 if (RT_UNLIKELY(cbReq < sizeof(*pReqHdr))) 2304 { 2305 OSDBGPRINT(("vboxdrv: Bad ioctl request size; cbReq=%#lx\n", (long)cbReq)); 2306 VBOXDRV_IOCTL_RETURN(pSession, uIOCtl, pReqHdr, VERR_INVALID_PARAMETER, VINF_SUCCESS); 2307 return VERR_INVALID_PARAMETER; 2308 } 2304 2309 if (RT_UNLIKELY( (pReqHdr->fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC 2305 2310 || pReqHdr->cbIn < sizeof(*pReqHdr) 2306 || pReqHdr->cbOut < sizeof(*pReqHdr))) 2311 || pReqHdr->cbIn > cbReq 2312 || pReqHdr->cbOut < sizeof(*pReqHdr) 2313 || pReqHdr->cbOut > cbReq)) 2307 2314 { 2308 2315 OSDBGPRINT(("vboxdrv: Bad ioctl request header; cbIn=%#lx cbOut=%#lx fFlags=%#lx\n", … … 4448 4455 && !memcmp(pImage->szName, pReq->u.In.szName, cchName)) 4449 4456 { 4450 /** @todo check cbImageBits and cbImageWithTabs here, if they differs that indicates that the images are different. */ 4451 pImage->cUsage++; 4452 pReq->u.Out.pvImageBase = pImage->pvImage; 4453 pReq->u.Out.fNeedsLoading = pImage->uState == SUP_IOCTL_LDR_OPEN; 4454 pReq->u.Out.fNativeLoader = pImage->fNative; 4455 supdrvLdrAddUsage(pSession, pImage); 4457 if (RT_LIKELY(pImage->cUsage < UINT32_MAX / 2U)) 4458 { 4459 /** @todo check cbImageBits and cbImageWithTabs here, if they differs that indicates that the images are different. */ 4460 pImage->cUsage++; 4461 pReq->u.Out.pvImageBase = pImage->pvImage; 4462 pReq->u.Out.fNeedsLoading = pImage->uState == SUP_IOCTL_LDR_OPEN; 4463 pReq->u.Out.fNativeLoader = pImage->fNative; 4464 supdrvLdrAddUsage(pSession, pImage); 4465 supdrvLdrUnlock(pDevExt); 4466 return VINF_SUCCESS; 4467 } 4456 4468 supdrvLdrUnlock(pDevExt); 4457 return VINF_SUCCESS; 4469 Log(("supdrvIOCtl_LdrOpen: To many existing references to '%s'!\n", pReq->u.In.szName)); 4470 return VERR_INTERNAL_ERROR_3; /** @todo add VERR_TOO_MANY_REFERENCES */ 4458 4471 } 4459 4472 } -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r52353 r52575 823 823 *******************************************************************************/ 824 824 /* SUPDrv.c */ 825 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr );825 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq); 826 826 int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession); 827 827 int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr); -
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r52192 r52575 689 689 return rc; 690 690 } 691 if (Hdr.cbIn < cbReq) 692 RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn) 691 693 } 692 694 else … … 699 701 * Process the IOCtl. 700 702 */ 701 int rc = supdrvIOCtl(iCmd, &g_DevExt, pSession, pHdr );703 int rc = supdrvIOCtl(iCmd, &g_DevExt, pSession, pHdr, cbReq); 702 704 if (RT_LIKELY(!rc)) 703 705 { -
trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
r52192 r52575 411 411 return rc; 412 412 } 413 if (Hdr.cbIn < cbReq) 414 RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn) 413 415 } 414 416 else … … 421 423 * Process the IOCtl. 422 424 */ 423 int rc = supdrvIOCtl(ulCmd, &g_VBoxDrvFreeBSDDevExt, pSession, pHdr );425 int rc = supdrvIOCtl(ulCmd, &g_VBoxDrvFreeBSDDevExt, pSession, pHdr, cbReq); 424 426 if (RT_LIKELY(!rc)) 425 427 { -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r52192 r52575 719 719 return -E2BIG; 720 720 } 721 if (RT_UNLIKELY( cbBuf != _IOC_SIZE(uCmd) && _IOC_SIZE(uCmd)))721 if (RT_UNLIKELY(_IOC_SIZE(uCmd) ? cbBuf != _IOC_SIZE(uCmd) : Hdr.cbIn < sizeof(Hdr))) 722 722 { 723 723 Log(("VBoxDrvLinuxIOCtl: bad ioctl cbBuf=%#x _IOC_SIZE=%#x; uCmd=%#x.\n", cbBuf, _IOC_SIZE(uCmd), uCmd)); … … 736 736 return -EFAULT; 737 737 } 738 if (Hdr.cbIn < cbBuf) 739 RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbBuf - Hdr.cbIn) 738 740 739 741 /* 740 742 * Process the IOCtl. 741 743 */ 742 rc = supdrvIOCtl(uCmd, &g_DevExt, pSession, pHdr );744 rc = supdrvIOCtl(uCmd, &g_DevExt, pSession, pHdr, cbBuf); 743 745 744 746 /* -
trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
r52192 r52575 335 335 * Process the IOCtl. 336 336 */ 337 rc = supdrvIOCtl(iFunction, &g_DevExt, pSession, pHdr );337 rc = supdrvIOCtl(iFunction, &g_DevExt, pSession, pHdr, cbReq); 338 338 } 339 339 else -
trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
r52553 r52575 816 816 * Process the IOCtl. 817 817 */ 818 rc = supdrvIOCtl(iCmd, &g_DevExt, pSession, pHdr );818 rc = supdrvIOCtl(iCmd, &g_DevExt, pSession, pHdr, cbBuf); 819 819 820 820 /* -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r52529 r52575 1009 1009 * Now call the common code to do the real work. 1010 1010 */ 1011 rc = supdrvIOCtl(uCmd, pDevExt, pSession, pHdr );1011 rc = supdrvIOCtl(uCmd, pDevExt, pSession, pHdr, cbBuf); 1012 1012 if (RT_SUCCESS(rc)) 1013 1013 { … … 1159 1159 && pStack->Parameters.DeviceIoControl.OutputBufferLength == pHdr->cbOut) 1160 1160 { 1161 /* Zero extra output bytes to make sure we don't leak anything. */ 1162 if (pHdr->cbIn < pHdr->cbOut) 1163 RtlZeroMemory((uint8_t *)pHdr + pHdr->cbIn, pHdr->cbOut - pHdr->cbIn); 1164 1161 1165 /* 1162 1166 * Do the job. 1163 1167 */ 1164 rc = supdrvIOCtl(pStack->Parameters.DeviceIoControl.IoControlCode, pDevExt, pSession, pHdr); 1168 rc = supdrvIOCtl(pStack->Parameters.DeviceIoControl.IoControlCode, pDevExt, pSession, pHdr, 1169 RT_MAX(pHdr->cbIn, pHdr->cbOut)); 1165 1170 if (!rc) 1166 1171 {
Note:
See TracChangeset
for help on using the changeset viewer.