diff -Nru virtualbox-4.3.36-dfsg/Config.kmk virtualbox-4.3.40-dfsg/Config.kmk --- virtualbox-4.3.36-dfsg/Config.kmk 2016-01-19 19:14:35.000000000 +0000 +++ virtualbox-4.3.40-dfsg/Config.kmk 2016-08-22 14:16:03.000000000 +0000 @@ -208,7 +208,7 @@ # This is the current build number. It should be increased every time we publish a # new build. The define is available in every source file. Only even build numbers # will be published, odd numbers are set during development. -VBOX_VERSION_BUILD = 36 +VBOX_VERSION_BUILD = 40 # The raw version string. This *must not* contain any other information/fields than # major, minor and build revision (as it is now) -- also will be used for host/guest version # comparison. @@ -2595,22 +2595,40 @@ # VBOX_PATH_SELFSIGN points to the Vista WDK bin/SelfSign directory. ifndef VBOX_PATH_SELFSIGN - VBOX_PATH_SELFSIGN := $(lastword $(sort $(wildcard $(PATH_DEVTOOLS)/win.x86/selfsign/*))) + VBOX_PATH_SELFSIGN := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS)/win.x86/selfsign/*))) ifeq ($(VBOX_PATH_SELFSIGN),) VBOX_PATH_SELFSIGN := $(PATH_DEVTOOLS)/win.x86/selfsign/r1 endif endif - VBOX_SIGNTOOL ?= $(PATH_DEVTOOLS)/bin/retry.cmd $(VBOX_PATH_SELFSIGN)/SignTool.exe - VBOX_INF2CAT ?= $(VBOX_PATH_SELFSIGN)/Inf2Cat.exe + ifndef VBOX_PATH_SIGN_TOOLS + VBOX_PATH_SIGN_TOOLS := $(firstword $(rsort $(wildcard \ + $(addprefix $(KBUILD_DEVTOOLS)/win.x86/sdk/v8.1*/Bin/, x86 $(if-expr $(KBUILD_HOST_ARCH)=="amd64",x64,) ) ))) + ifeq ($(VBOX_PATH_SIGN_TOOLS),) + VBOX_PATH_SIGN_TOOLS := $(firstword $(rsort $(wildcard \ + $(addprefix $(KBUILD_DEVTOOLS)/win.x86/sdk/v10*/Bin/, x86 $(if-expr $(KBUILD_HOST_ARCH)=="amd64",x64,) ) ))) + ifeq ($(VBOX_PATH_SIGN_TOOLS),) + VBOX_PATH_SIGN_TOOLS := $(VBOX_PATH_SELFSIGN) + endif + endif + endif - # There are three signing modes; 'test', 'development' and 'release'. - ifeq ($(strip $(VBOX_SIGNING_MODE)),test) + VBOX_RETRY ?= $(ASH) $(KBUILD_DEVTOOLS)/bin/retry.sh + VBOX_SIGNTOOL ?= $(VBOX_RETRY) "$(VBOX_PATH_SIGN_TOOLS)/signtool.exe" + VBOX_INF2CAT ?= $(VBOX_PATH_SELFSIGN)/inf2cat.exe + + ifeq ($(VBOX_SIGNING_MODE),test) VBOX_CERTIFICATE_SUBJECT_NAME ?= MyTestCertificate VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)" else if1of ($(VBOX_SIGNING_MODE), release development) VBOX_CERTIFICATE_SUBJECT_NAME ?= Oracle Corporation VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)" /a - VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/VeriSign Class 3 Public Primary Certification Authority - G5.cer + VBOX_CERTIFICATE_FINGERPRINT ?= 7e 92 b6 6b e5 1b 79 d8 ce 3f f2 5c 15 c2 df 6a b8 c7 f2 f2 + # TEMPORARY HACK! + if defined(VBOX_ONLY_VALIDATIONKIT) + VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/MSCV-VSClass3.cer + else + VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/VeriSign Class 3 Public Primary Certification Authority - G5.cer + endif VBOX_CROSS_CERTIFICATE_FILE_ARGS ?= /ac "$(VBOX_CROSS_CERTIFICATE_FILE)" VBOX_TSA_URL ?= http://timestamp.verisign.com/scripts/timestamp.dll VBOX_TSA_URL_ARGS ?= /t "$(VBOX_TSA_URL)" @@ -2622,13 +2640,40 @@ VBOX_CERTIFICATE_FINGERPRINT_ARGS := $(if-expr "$(VBOX_CERTIFICATE_FINGERPRINT)" != "" \ ,/sha1 "$(subst $(SP),,$(VBOX_CERTIFICATE_FINGERPRINT))",) + ifeq ($(VBOX_SIGNING_MODE),test) + #VBOX_CERTIFICATE_SHA2_SUBJECT_NAME ?= MyTestCertificateSha2 + VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME)" + else # release + VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME)" /a + VBOX_CERTIFICATE_SHA2_FINGERPRINT ?= 31 31 bb 58 8b 19 9e 6e 85 0f d3 35 82 b0 c5 82 55 e1 6c 49 + # TEMPORARY HACK for the validation kitty! The build box is too old. + if defined(VBOX_ONLY_VALIDATIONKIT) + VBOX_CROSS_CERTIFICATE_SHA2_FILE ?= $(VBOX_PATH_SELFSIGN)/MSCV-VSClass3.cer + else + VBOX_CERTIFICATE_SHA2_SUBJECT_NAME ?= Oracle Corporation + VBOX_CROSS_CERTIFICATE_SHA2_FILE ?= $(VBOX_PATH_SELFSIGN)/VeriSign Class 3 Public Primary Certification Authority - G5.cer + endif + VBOX_CROSS_CERTIFICATE_SHA2_FILE_ARGS ?= /ac "$(VBOX_CROSS_CERTIFICATE_SHA2_FILE)" + VBOX_TSA_SHA2_URL ?= http://sha256timestamp.ws.symantec.com/sha256/timestamp + VBOX_TSA_SHA2_URL_ARGS ?= /tr "$(VBOX_TSA_SHA2_URL)" + endif + VBOX_CERTIFICATE_SHA2_STORE ?= my + VBOX_CERTIFICATE_SHA2_STORE_ARGS ?= /s "$(VBOX_CERTIFICATE_SHA2_STORE)" + VBOX_CERTIFICATE_SHA2_FINGERPRINT_ARGS := $(if-expr "$(VBOX_CERTIFICATE_SHA2_FINGERPRINT)" != "" \ + ,/sha1 "$(subst $(SP),,$(VBOX_CERTIFICATE_SHA2_FINGERPRINT))",) # Still using SHA-1 for fingerprinting, it's good enough for that! + ## Commands for signing a driver image after link. - VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out))) + VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out),,2)) ## Sign a file (generic). # @param 1 The file to sign. # @param 2 File description. Optional. # @param 3 Additional parameters. Optional. - VBOX_SIGN_FILE_FN ?= $(VBOX_SIGNTOOL) sign \ + # @param 4 Set to 2 if the expression will be expanded twice before chopped into commands (for _CMDS). + # @param 5 Disables dual signing if non-empty. + ifndef VBOX_SIGN_FILE_FN + ifdef VBOX_CERTIFICATE_SHA2_SUBJECT_NAME + VBOX_SIGN_FILE_FN = $(VBOX_SIGNTOOL) \ + sign /fd sha1\ $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \ $(VBOX_CERTIFICATE_STORE_ARGS) \ $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \ @@ -2636,11 +2681,36 @@ $(VBOX_TSA_URL_ARGS) \ $(if $(strip $(2)),/d "$(strip $(2))",) \ $(3) \ + $(1) \ + $(if-expr "$5" == "",\ + $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(VBOX_SIGNTOOL) \ + sign /as /fd sha256 \ + $(VBOX_CROSS_CERTIFICATE_SHA2_FILE_ARGS) \ + $(VBOX_CERTIFICATE_SHA2_STORE_ARGS) \ + $(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS) \ + $(VBOX_CERTIFICATE_SHA2_FINGERPRINT_ARGS) \ + $(VBOX_TSA_SHA2_URL_ARGS) \ + $(if $(strip $(2)),/d "$(strip $(2))",) \ + $(3) \ + $(1),) + else + VBOX_SIGN_FILE_FN = $(VBOX_SIGNTOOL) sign \ + $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \ + $(VBOX_CERTIFICATE_STORE_ARGS) \ + $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \ + $(VBOX_CERTIFICATE_FINGERPRINT_ARGS) \ + $(VBOX_TSA_URL_ARGS) \ + $(if $(strip $(2)),/d "$(strip $(2))",) \ + $(3) \ $(1) + endif + endif + ## Sign an executable image. # @param 1 The file to sign. # @param 2 File description. Optional. - VBOX_SIGN_IMAGE_FN ?= $(call VBOX_SIGN_FILE_FN,$(1),$(2),/ph) + # @param 3 Set to 2 if the expression will be expanded twice before chopped into commands (for _CMDS). + VBOX_SIGN_IMAGE_FN ?= $(call VBOX_SIGN_FILE_FN,$(1),$(2),/ph,$(3)) ## Create a security catalog file. # @param 1 The directory containing the stuff to sign. @@ -2650,7 +2720,7 @@ $(RM) -f $(2)\ $(NL)$(TAB)$(VBOX_INF2CAT) /driver:$(strip $(1)) /os:$(strip $(subst ;,$(COMMA),$(3))) /verbose \ $(NL)$(TAB)$(MV) $(2) $(2) \ - $(NL)$(TAB)$(call VBOX_SIGN_FILE_FN,$(2)) + $(NL)$(TAB)$(call VBOX_SIGN_FILE_FN,$(2),,,$(NL)$(TAB)) VBOX_MAKE_CAT64_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),XP_X64;Server2003_X64;Vista_X64) VBOX_MAKE_CAT32_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),2000;XP_X86;Server2003_X86;Vista_X86) ifeq ($(KBUILD_TARGET_ARCH),x86) @@ -2662,7 +2732,7 @@ # Go nuts, sign everything. if "$(strip $(VBOX_SIGNING_MODE))" == "release" || defined(VBOX_WITH_HARDENING) ## Commands for signing an executable or a dll image after link. - VBOX_SIGN_IMAGE_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out))) + VBOX_SIGN_IMAGE_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out),,2)) endif ## Enable signing of the additions. VBOX_SIGN_ADDITIONS ?= 1 @@ -2926,12 +2996,12 @@ ifdef VBOX_WITH_S3 VBOX_WITH_LIBCURL = 1 SDK_VBOX_LIBCURL = . -SDK_VBOX_LIBCURL_INCS ?= $(PATH_ROOT)/src/libs/curl-7.45.0/include +SDK_VBOX_LIBCURL_INCS ?= $(PATH_ROOT)/src/libs/curl-7.47.0/include SDK_VBOX_LIBCURL_LIBS ?= $(PATH_STAGE_LIB)/VBox-libcurl$(VBOX_SUFF_LIB) SDK_VBOX_LIBCURL_DEFS ?= BUILDING_LIBCURL SDK_VBOX_LIBCURL-x86 = . -SDK_VBOX_LIBCURL-x86_INCS ?= $(PATH_ROOT)/src/libs/curl-7.45.0/include +SDK_VBOX_LIBCURL-x86_INCS ?= $(PATH_ROOT)/src/libs/curl-7.47.0/include SDK_VBOX_LIBCURL-x86_LIBS.x86 ?= $(PATH_STAGE_LIB)/VBox-libcurl-x86$(VBOX_SUFF_LIB) SDK_VBOX_LIBCURL-x86_DEFS ?= BUILDING_LIBCURL endif @@ -3125,7 +3195,7 @@ endif TEMPLATE_VBoxRc_CFLAGS = $(TEMPLATE_VBoxRc_CXXFLAGS) TEMPLATE_VBoxRc_LDFLAGS = \ - -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug \ + -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug -Opt:Ref -Opt:Icf \ -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com ifdef VBOX_SIGNING_MODE @@ -3190,7 +3260,7 @@ ifeq ($(VBOX_LDR_FMT32),pe) TEMPLATE_VBoxRcExe_LDFLAGS = \ - -Incremental:NO -MapInfo:Exports -NoD -Debug \ + -Incremental:NO -MapInfo:Exports -NoD -Debug -Opt:Ref -Opt:Icf \ -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com TEMPLATE_VBoxRcExe_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK) @@ -3260,7 +3330,7 @@ endif TEMPLATE_VBoxR0_CFLAGS = $(TEMPLATE_VBoxR0_CXXFLAGS) TEMPLATE_VBoxR0_LDFLAGS = \ - -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug \ + -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug -Opt:Ref -Opt:Icf \ -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com ifdef VBOX_WITH_DTRACE_R0 @@ -3373,7 +3443,7 @@ TEMPLATE_VBOXR0DRV_CXXFLAGS = -Zi -Zl -GR- -EHs- -GF -Gz -W3 -GS- -wd4996 -Zc:wchar_t- -Gs4096 $(VBOX_VCC_OPT) $(VBOX_VCC_FP) TEMPLATE_VBOXR0DRV_CFLAGS = $(TEMPLATE_VBOXR0DRV_CXXFLAGS) TEMPLATE_VBOXR0DRV_LDFLAGS = \ - -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD -Release -Debug \ + -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD -Release -Debug -Opt:Ref -Opt:Icf \ -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com ifdef VBOX_WITH_DTRACE_R0DRV @@ -3673,7 +3743,7 @@ TEMPLATE_VBOXR3EXE_CFLAGS.dbgopt = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.dbgopt) TEMPLATE_VBOXR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile) TEMPLATE_VBOXR3EXE_LDFLAGS = \ - /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug \ + /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \ /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com \ /DISALLOWLIB:libc.lib \ @@ -4357,7 +4427,7 @@ TEMPLATE_VBOXMAINEXE_CFLAGS.dbgopt = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.dbgopt) TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile) TEMPLATE_VBOXMAINEXE_LDFLAGS = \ - /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug \ + /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \ /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com \ /DISALLOWLIB:libc.lib \ @@ -4815,7 +4885,7 @@ TEMPLATE_VBOXQT4GUIEXE_INCS += \ $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_INC) TEMPLATE_VBOXQT4GUIEXE_LDFLAGS = \ - /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug \ + /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \ /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_HARDENING) @@ -5003,7 +5073,7 @@ TEMPLATE_VBoxBldProg_CFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile) TEMPLATE_VBoxBldProg_CFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile) TEMPLATE_VBoxBldProg_LDFLAGS = \ - /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug \ + /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \ /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \ /DISALLOWLIB:libc$(VBOX_VCC_CRT_TYPE_N).lib \ /DISALLOWLIB:libcmt$(VBOX_VCC_CRT_TYPE_N).lib \ @@ -5737,7 +5807,7 @@ SVN ?= svn$(HOSTSUFF_EXE) VBOX_SVN_REV_KMK = $(PATH_OUT)/revision.kmk ifndef VBOX_SVN_REV - VBOX_SVN_REV_FALLBACK := $(patsubst %:,, $Rev: 105129 $ ) + VBOX_SVN_REV_FALLBACK := $(patsubst %:,, $Rev: 110317 $ ) VBOX_SVN_DEP := $(firstword $(wildcard $(PATH_ROOT)/.svn/wc.db $(abspath $(PATH_ROOT)/../.svn/wc.db) $(abspath $(PATH_ROOT)/../../.svn/wc.db) $(PATH_ROOT)/.svn/entries)) ifeq ($(which $(SVN)),) VBOX_SVN_DEP := diff -Nru virtualbox-4.3.36-dfsg/configure virtualbox-4.3.40-dfsg/configure --- virtualbox-4.3.36-dfsg/configure 2016-01-19 19:14:35.000000000 +0000 +++ virtualbox-4.3.40-dfsg/configure 2016-08-22 14:16:03.000000000 +0000 @@ -421,9 +421,9 @@ -o \( $cc_maj -eq 3 -a $cc_min -lt 2 \) \ -o \( $cc_maj -eq 4 -a $cc_min -lt 1 -a "$OS" != "darwin" \) \ -o \( $cc_maj -eq 4 -a $cc_min -gt 9 \) \ - -o \( $cc_maj -eq 5 -a $cc_min -gt 1 \) \ + -o \( $cc_maj -eq 5 -a $cc_min -gt 9 \) \ -o $cc_maj -gt 5 ]; then - log_failure "gcc version $cc_maj.$cc_min found, expected gcc 3.x with x>1 or gcc 4.x with 0 Mon, 21 Jan 2019 14:33:14 +0100 + +virtualbox (4.3.36-dfsg-1+deb8u1ubuntu1.14.04.3) trusty; urgency=medium + + * debian/patches/fix-compile-for-xenial-kernel.patch + - Fix for LP: #1818049 (virtualbox dkms modules fail to build with + linux 4.4.0-143.169) + + -- Gianfranco Costamagna Mon, 11 Mar 2019 17:53:54 +0100 + virtualbox (4.3.36-dfsg-1+deb8u1ubuntu1.14.04.2) trusty-security; urgency=medium * debian/patches/fix-for-guest-to-host-escape-vulnerability.patch: diff -Nru virtualbox-4.3.36-dfsg/debian/patches/fix-compile-for-xenial-kernel.patch virtualbox-4.3.40-dfsg/debian/patches/fix-compile-for-xenial-kernel.patch --- virtualbox-4.3.36-dfsg/debian/patches/fix-compile-for-xenial-kernel.patch 1970-01-01 00:00:00.000000000 +0000 +++ virtualbox-4.3.40-dfsg/debian/patches/fix-compile-for-xenial-kernel.patch 2019-01-21 13:33:14.000000000 +0000 @@ -0,0 +1,18 @@ +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +@@ -1071,8 +1071,15 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser + pTask->mm, /* Whose pages. */ + R3Ptr, /* Where from. */ + cPages, /* How many pages. */ ++# if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168)) && \ ++ (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) ++ fWrite ? FOLL_WRITE | /* Write to memory. */ ++ FOLL_FORCE /* force write access. */ ++ : 0, ++# else + fWrite, /* Write to memory. */ + fWrite, /* force write access. */ ++# endif + &pMemLnx->apPages[0], /* Page array. */ + papVMAs); /* vmas */ + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) */ diff -Nru virtualbox-4.3.36-dfsg/debian/patches/series virtualbox-4.3.40-dfsg/debian/patches/series --- virtualbox-4.3.36-dfsg/debian/patches/series 2019-01-17 16:49:01.000000000 +0000 +++ virtualbox-4.3.40-dfsg/debian/patches/series 2019-01-21 13:33:14.000000000 +0000 @@ -15,3 +15,4 @@ 35-libvdeplug-soname.patch 36-fix-vnc-version-string.patch fix-guest-to-host-escape-vulnerability.patch +fix-compile-for-xenial-kernel.patch diff -Nru virtualbox-4.3.36-dfsg/doc/manual/user_ChangeLogImpl.xml virtualbox-4.3.40-dfsg/doc/manual/user_ChangeLogImpl.xml --- virtualbox-4.3.36-dfsg/doc/manual/user_ChangeLogImpl.xml 2016-01-19 19:14:36.000000000 +0000 +++ virtualbox-4.3.40-dfsg/doc/manual/user_ChangeLogImpl.xml 2016-08-22 14:16:04.000000000 +0000 @@ -1,7 +1,107 @@ - Version 4.3.36 (201x-xx-xx) + Version 4.3.40 (2016-08-22) + + This is a maintenance release. The following items were fixed and/or + added: + + + + + Storage: fixed a possible endless reconnect loop for the iSCSI backend + if connecting to the target succeeds but further I/O requests cause a + disconnect + + + + Storage: fixed a bug when resizing certain VDI images which resulted in + using the whole disk on the host (bug #15582) + + + + SDK: reduced memory usage in the webservice Java bindings + + + + Linux hosts: fix for Linux 4.5 if + CONFIG_NET_CLS_ACT is enabled (bug #15327) + + + + Linux hosts: EL 6.8 fix (ticket #15411) + + + + Linux hosts: Linux 4.7 fix (bug #15459) + + + + Windows hosts: hardening fixes + + + + + + + Version 4.3.38 (2016-04-19) + + This is a maintenance release. The following items were fixed and/or + added: + + + + + VMM: fixed a problem which could lead to a wrong guest behavior on + AMD CPUs (bugs #14831 and #15186) + + + + NAT Network: fixed 100% CPU load in VBoxNetNAT on Mac OS X + under certain circumstances (bug #15223) + + + + BIOS: fixed int15/AH=83/AL=00 function (4.2.0 regression) + + + + Linux hosts / guests: Linux 4.5 fixes (bug #15251) + + + + Linux hosts / guests: Linux 4.6 fixes (bug #15298) + + + + Windows hosts: fixed Python installation path (bug #13131) + + + + Windows hosts / guests: properly sign binaries using a sha-256 + certificate (bug #15024) + + + + Windows hosts: hardening fixes required for recent Windows 10 + insider builds (bugs #14052, #15245 and #15296) + + + + Windows Additions: fixed sporadical failure of the graphics driver + in Windows 10 guests (bug #14409) + + + + Windows Additions: fixed a hang with PowerPoint 2010 and the WDDM + drivers if Aero is disabled + + + + + + + Version 4.3.36 (2016-01-19) This is a maintenance release. The following items were fixed and/or added: @@ -11,7 +111,7 @@ GUI: improved handling of text selection mouse pointer (bug #750) - + GUI: properly limit the number of VCPUs to the number of physical cores on Mac OS X (bug #15018) diff -Nru virtualbox-4.3.36-dfsg/include/iprt/asm.h virtualbox-4.3.40-dfsg/include/iprt/asm.h --- virtualbox-4.3.36-dfsg/include/iprt/asm.h 2016-01-19 19:14:39.000000000 +0000 +++ virtualbox-4.3.40-dfsg/include/iprt/asm.h 2016-08-22 14:16:07.000000000 +0000 @@ -3438,6 +3438,45 @@ /** + * Checks if a memory block is all zeros. + * + * @returns Pointer to the first non-zero byte. + * @returns NULL if all zero. + * + * @param pv Pointer to the memory block. + * @param cb Number of bytes in the block. + * + * @todo Fix name, it is a predicate function but it's not returning boolean! + */ +DECLINLINE(void *) ASMMemFirstNonZero(void const *pv, size_t cb) +{ + uint8_t const *pb = (uint8_t const *)pv; + for (; cb; cb--, pb++) + if (RT_LIKELY(*pb == 0)) + { /* likely */ } + else + return (void *)pb; + return NULL; +} + + +/** + * Checks if a memory block is all zeros. + * + * @returns true if zero, false if not. + * + * @param pv Pointer to the memory block. + * @param cb Number of bytes in the block. + * + * @sa ASMMemFirstNonZero + */ +DECLINLINE(bool) ASMMemIsZero(void const *pv, size_t cb) +{ + return ASMMemFirstNonZero(pv, cb) == NULL; +} + + +/** * Checks if a memory page is all zeros. * * @returns true / false. diff -Nru virtualbox-4.3.36-dfsg/include/iprt/err.h virtualbox-4.3.40-dfsg/include/iprt/err.h --- virtualbox-4.3.36-dfsg/include/iprt/err.h 2016-01-19 19:14:40.000000000 +0000 +++ virtualbox-4.3.40-dfsg/include/iprt/err.h 2016-08-22 14:16:08.000000000 +0000 @@ -1432,6 +1432,8 @@ #define VERR_LDRPE_LOAD_CONFIG_SIZE (-626) /** The PE loader encountered a lock prefix table, a feature which hasn't been implemented yet. */ #define VERR_LDRPE_LOCK_PREFIX_TABLE (-627) +/** The PE loader encountered some Guard CF stuff in the load config. */ +#define VERR_LDRPE_GUARD_CF_STUFF (-628) /** The ELF loader doesn't handle foreign endianness. */ #define VERR_LDRELF_ODD_ENDIAN (-630) /** The ELF image is 'dynamic', the ELF loader can only deal with 'relocatable' images at present. */ diff -Nru virtualbox-4.3.36-dfsg/src/libs/kStuff/kStuff/include/k/kHlpAssert.h virtualbox-4.3.40-dfsg/src/libs/kStuff/kStuff/include/k/kHlpAssert.h --- virtualbox-4.3.36-dfsg/src/libs/kStuff/kStuff/include/k/kHlpAssert.h 2012-03-17 01:39:33.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/kStuff/kStuff/include/k/kHlpAssert.h 2015-08-13 09:03:02.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: kHlpAssert.h 46 2012-03-17 01:39:33Z bird $ */ +/* $Id: kHlpAssert.h 70 2015-08-13 09:03:02Z bird $ */ /** @file * kHlpAssert - Assertion Macros. */ @@ -57,13 +57,22 @@ # error "Port Me" #endif +/** @def K_FUNCTION + * Undecorated function name macro expanded by the compiler. + */ +#if defined(__GNUC__) +# define K_FUNCTION __func__ +#else +# define K_FUNCTION __FUNCTION__ +#endif + #ifdef K_STRICT # define kHlpAssert(expr) \ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ } \ } while (0) @@ -72,7 +81,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ stmt; \ } \ @@ -82,7 +91,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ return (rcRet); \ } \ @@ -92,7 +101,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ stmt; \ return (rcRet); \ @@ -103,7 +112,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ return; \ } \ @@ -113,7 +122,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertBreakpoint(); \ stmt; \ return; \ @@ -124,7 +133,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ } \ @@ -134,7 +143,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ stmt; \ @@ -145,7 +154,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ return (rcRet); \ @@ -156,7 +165,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ stmt; \ @@ -168,7 +177,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ return; \ @@ -179,7 +188,7 @@ do { \ if (!(expr)) \ { \ - kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kHlpAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kHlpAssertMsg2 msg; \ kHlpAssertBreakpoint(); \ stmt; \ diff -Nru virtualbox-4.3.36-dfsg/src/libs/kStuff/kStuff/kDbg/kDbgHlp.h virtualbox-4.3.40-dfsg/src/libs/kStuff/kStuff/kDbg/kDbgHlp.h --- virtualbox-4.3.36-dfsg/src/libs/kStuff/kStuff/kDbg/kDbgHlp.h 2009-07-01 20:30:29.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/kStuff/kStuff/kDbg/kDbgHlp.h 2015-08-13 09:03:02.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: kDbgHlp.h 29 2009-07-01 20:30:29Z bird $ */ +/* $Id: kDbgHlp.h 70 2015-08-13 09:03:02Z bird $ */ /** @file * kDbg - The Debug Info Reader, Internal Header. */ @@ -242,7 +242,7 @@ do { \ if (!(expr)) \ { \ - kDbgAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kDbgAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kDbgAssertBreakpoint(); \ } } while (0) @@ -251,7 +251,7 @@ do { \ if (!(expr)) \ { \ - kDbgAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kDbgAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kDbgAssertBreakpoint(); \ return (rcRet); \ } @@ -261,7 +261,7 @@ do { \ if (!(expr)) \ { \ - kDbgAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kDbgAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kDbgAssertMsg2 msg; \ kDbgAssertBreakpoint(); \ } @@ -271,7 +271,7 @@ do { \ if (!(expr)) \ { \ - kDbgAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ + kDbgAssertMsg1(#expr, __FILE__, __LINE__, K_FUNCTION); \ kDbgAssertMsg2 msg; \ kDbgAssertBreakpoint(); \ return (rcRet); \ diff -Nru virtualbox-4.3.36-dfsg/src/libs/Makefile.kmk virtualbox-4.3.40-dfsg/src/libs/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/libs/Makefile.kmk 2016-01-19 19:19:13.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/Makefile.kmk 2016-08-22 14:20:56.000000000 +0000 @@ -39,8 +39,8 @@ # Libcurl for inet access if defined(VBOX_WITH_LIBCURL) && !defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS) && !defined(VBOX_ONLY_SDK) && !defined(VBOX_ONLY_TESTSUITE) \ - && "$(SDK_VBOX_LIBCURL_INCS)" == "$(PATH_ROOT)/src/libs/curl-7.45.0/include" - include $(PATH_SUB_CURRENT)/curl-7.45.0/Makefile.kmk + && "$(SDK_VBOX_LIBCURL_INCS)" == "$(PATH_ROOT)/src/libs/curl-7.47.0/include" + include $(PATH_SUB_CURRENT)/curl-7.47.0/Makefile.kmk endif # The kStuff lib used by IPRT and the debugger. @@ -52,7 +52,7 @@ if !defined(VBOX_ONLY_SDK) \ && ( "$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)" \ || defined(VBOX_WITH_EXTPACK_PUEL_BUILD)) - include $(PATH_SUB_CURRENT)/openssl-1.0.1q/Makefile.kmk + include $(PATH_SUB_CURRENT)/openssl-1.0.1t/Makefile.kmk endif # libjpeg for VRDP video redirection diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/Makefile.kmk virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/Makefile.kmk 2016-01-19 19:19:22.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/Makefile.kmk 2016-08-22 14:21:03.000000000 +0000 @@ -524,6 +524,7 @@ _POSIX_SOURCE=1 \ _BSD_SOURCE=1 \ _SVID_SOURCE=1 \ + _DEFAULT_SOURCE \ _REENTRANT=1 \ _LARGEFILE64_SOURCE=1 \ HAVE_FCNTL_FILE_LOCKING=1 \ diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp 2016-01-19 19:19:40.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/os2/xptcstubs_gcc_x86_os2.cpp 2016-08-22 14:21:21.000000000 +0000 @@ -64,14 +64,13 @@ self->GetInterfaceInfo(&iface_info); NS_ASSERTION(iface_info,"no interface info"); + if (!iface_info) + return NS_ERROR_UNEXPECTED; iface_info->GetMethodInfo(PRUint16(methodIndex), &info); - NS_ASSERTION(info,"no interface info"); - -#ifdef VBOX + NS_ASSERTION(info,"no method info"); if (!info) - return result; -#endif + return NS_ERROR_UNEXPECTED; paramCount = info->GetParamCount(); @@ -81,6 +80,8 @@ else dispatchParams = paramBuffer; NS_ASSERTION(dispatchParams,"no place for params"); + if (!dispatchParams) + return NS_ERROR_OUT_OF_MEMORY; PRUint32* ap = args; for(i = 0; i < paramCount; i++, ap++) diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_darwin.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_darwin.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_darwin.cpp 2016-01-19 19:19:41.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_darwin.cpp 2016-08-22 14:21:22.000000000 +0000 @@ -66,7 +66,7 @@ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; nsXPTCMiniVariant* dispatchParams = NULL; nsIInterfaceInfo* iface_info = NULL; - const nsXPTMethodInfo* info; + const nsXPTMethodInfo* info = NULL; PRUint32 paramCount; PRUint32 i; nsresult result = NS_ERROR_FAILURE; diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp 2016-01-19 19:19:41.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_gcc_x86_unix.cpp 2016-08-22 14:21:22.000000000 +0000 @@ -66,12 +66,9 @@ return NS_ERROR_UNEXPECTED; iface_info->GetMethodInfo(PRUint16(methodIndex), &info); - NS_ASSERTION(info,"no interface info"); - -#ifdef VBOX + NS_ASSERTION(info,"no method info"); if (!info) - return result; -#endif + return NS_ERROR_UNEXPECTED; paramCount = info->GetParamCount(); @@ -81,6 +78,8 @@ else dispatchParams = paramBuffer; NS_ASSERTION(dispatchParams,"no place for params"); + if (!dispatchParams) + return NS_ERROR_OUT_OF_MEMORY; PRUint32* ap = args; for(i = 0; i < paramCount; i++, ap++) diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp 2016-01-19 19:19:41.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_x86.cpp 2016-08-22 14:21:23.000000000 +0000 @@ -49,7 +49,7 @@ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; nsXPTCMiniVariant* dispatchParams = NULL; nsIInterfaceInfo* iface_info = NULL; - const nsXPTMethodInfo* info; + const nsXPTMethodInfo* info = NULL; PRUint8 paramCount; PRUint8 i; nsresult result = NS_ERROR_FAILURE; @@ -58,9 +58,13 @@ self->GetInterfaceInfo(&iface_info); NS_ASSERTION(iface_info,"no interface info"); + if (!iface_info) + return NS_ERROR_UNEXPECTED; iface_info->GetMethodInfo(PRUint16(methodIndex), &info); - NS_ASSERTION(info,"no interface info"); + NS_ASSERTION(info,"no method info"); + if (!info) + return NS_ERROR_UNEXPECTED; paramCount = info->GetParamCount(); @@ -70,6 +74,8 @@ else dispatchParams = paramBuffer; NS_ASSERTION(dispatchParams,"no place for params"); + if (!dispatchParams) + return NS_ERROR_OUT_OF_MEMORY; PRUint32* ap = args; for(i = 0; i < paramCount; i++, ap++) diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp 2016-01-19 19:19:41.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp 2016-08-22 14:21:23.000000000 +0000 @@ -66,7 +66,7 @@ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; nsXPTCMiniVariant* dispatchParams = NULL; nsIInterfaceInfo* iface_info = NULL; - const nsXPTMethodInfo* info; + const nsXPTMethodInfo* info = NULL; PRUint32 paramCount; PRUint32 i; nsresult result = NS_ERROR_FAILURE; diff -Nru virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp --- virtualbox-4.3.36-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp 2016-01-19 19:19:41.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp 2016-08-22 14:21:23.000000000 +0000 @@ -49,7 +49,7 @@ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; nsXPTCMiniVariant* dispatchParams = NULL; nsIInterfaceInfo* iface_info = NULL; - const nsXPTMethodInfo* info; + const nsXPTMethodInfo* info = NULL; PRUint8 paramCount; PRUint8 i; nsresult result = NS_ERROR_FAILURE; @@ -58,9 +58,13 @@ self->GetInterfaceInfo(&iface_info); NS_ASSERTION(iface_info,"no interface info"); + if (!iface_info) + return NS_ERROR_UNEXPECTED; iface_info->GetMethodInfo(PRUint16(methodIndex), &info); - NS_ASSERTION(info,"no interface info"); + NS_ASSERTION(info,"no method info"); + if (!info) + return NS_ERROR_UNEXPECTED; paramCount = info->GetParamCount(); @@ -70,6 +74,8 @@ else dispatchParams = paramBuffer; NS_ASSERTION(dispatchParams,"no place for params"); + if (!dispatchParams) + return NS_ERROR_OUT_OF_MEMORY; PRUint32* ap = args; for(i = 0; i < paramCount; i++, ap++) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Additions/linux/sharedfolders/lnkops.c virtualbox-4.3.40-dfsg/src/VBox/Additions/linux/sharedfolders/lnkops.c --- virtualbox-4.3.36-dfsg/src/VBox/Additions/linux/sharedfolders/lnkops.c 2016-01-19 19:14:51.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Additions/linux/sharedfolders/lnkops.c 2016-08-22 14:16:19.000000000 +0000 @@ -76,10 +76,10 @@ path = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!path) return ERR_PTR(-ENOMEM); - rc = VbglR0SfReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path); + rc = vboxReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path); if (RT_FAILURE(rc)) { - LogFunc(("VbglR0SfReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc)); + LogFunc(("vboxReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc)); kfree(path); return ERR_PTR(-EPROTO); } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Additions/linux/sharedfolders/regops.c virtualbox-4.3.40-dfsg/src/VBox/Additions/linux/sharedfolders/regops.c --- virtualbox-4.3.36-dfsg/src/VBox/Additions/linux/sharedfolders/regops.c 2016-01-19 19:14:51.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Additions/linux/sharedfolders/regops.c 2016-08-22 14:16:19.000000000 +0000 @@ -712,7 +712,11 @@ } unlock_page(page); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) + put_page(page); +#else page_cache_release(page); +#endif return nwritten; } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Additions/Makefile.kmk virtualbox-4.3.40-dfsg/src/VBox/Additions/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/VBox/Additions/Makefile.kmk 2016-01-19 19:14:42.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Additions/Makefile.kmk 2016-08-22 14:16:09.000000000 +0000 @@ -238,6 +238,7 @@ OS2/libc063.dll=$(VBOX_PATH_ADDITIONS.os2.x86)/libc063.dll \ OS2/libc064.dll=$(VBOX_PATH_ADDITIONS.os2.x86)/libc064.dll \ OS2/libc065.dll=$(VBOX_PATH_ADDITIONS.os2.x86)/libc065.dll \ + OS2/libc066.dll=$(VBOX_PATH_ADDITIONS.os2.x86)/libc066.dll \ OS2/readme.txt=$(VBOX_PATH_ADDITIONS.os2.x86)/readme.txt \ \ OS2/gengradd.dll=$(VBOX_PATH_ADDITIONS.os2.x86)/gengradd.dll \ diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Additions/x11/vboxmouse/Makefile.kmk virtualbox-4.3.40-dfsg/src/VBox/Additions/x11/vboxmouse/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/VBox/Additions/x11/vboxmouse/Makefile.kmk 2016-01-19 19:14:53.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Additions/x11/vboxmouse/Makefile.kmk 2016-08-22 14:16:20.000000000 +0000 @@ -37,7 +37,7 @@ # unsigned long is 64bits vboxmouse_drv_DEFS.amd64 += _XSERVER64 vboxmouse_drv_DEFS += \ - _POSIX_C_SOURCE=199309L _POSIX_SOURCE _XOPEN_SOURCE \ + _POSIX_C_SOURCE=199309L _POSIX_SOURCE _XOPEN_SOURCE _DEFAULT_SOURCE \ _BSD_SOURCE _SVID_SOURCE _GNU_SOURCE SHAPE XINPUT XKB LBX XAPPGROUP \ XCSECURITY TOGCUP XF86BIGFONT DPMSExtension PIXPRIV PANORAMIX RENDER \ GCCUSESGAS AVOID_GLYPHBLT PIXPRIV SINGLEDEPTH XFreeXDGA XvExtension \ diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Additions/x11/vboxvideo/Makefile.kmk virtualbox-4.3.40-dfsg/src/VBox/Additions/x11/vboxvideo/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/VBox/Additions/x11/vboxvideo/Makefile.kmk 2016-01-19 19:14:53.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Additions/x11/vboxvideo/Makefile.kmk 2016-08-22 14:16:21.000000000 +0000 @@ -63,7 +63,7 @@ # unsigned long is 64bits vboxvideo_drv_DEFS.amd64 += _XSERVER64 vboxvideo_drv_DEFS = \ - _POSIX_C_SOURCE=199309L _POSIX_SOURCE _XOPEN_SOURCE \ + _POSIX_C_SOURCE=199309L _POSIX_SOURCE _XOPEN_SOURCE _DEFAULT_SOURCE \ _BSD_SOURCE _SVID_SOURCE _GNU_SOURCE SHAPE XINPUT XKB LBX XAPPGROUP \ XCSECURITY TOGCUP XF86BIGFONT DPMSExtension PIXPRIV PANORAMIX RENDER \ GCCUSESGAS AVOID_GLYPHBLT PIXPRIV SINGLEDEPTH XFreeXDGA XvExtension \ Binary files /tmp/tmpwuYfGj/UZmbvcyof1/virtualbox-4.3.36-dfsg/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd and /tmp/tmpwuYfGj/d4XGGU5IR3/virtualbox-4.3.40-dfsg/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd differ Binary files /tmp/tmpwuYfGj/UZmbvcyof1/virtualbox-4.3.36-dfsg/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd and /tmp/tmpwuYfGj/d4XGGU5IR3/virtualbox-4.3.40-dfsg/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd differ diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.asm virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.asm --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.asm 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.asm 2016-08-22 14:19:26.000000000 +0000 @@ -6779,7 +6779,7 @@ section _DATA progbits vstart=0x4800 align=1 ; size=0x36e1 class=DATA group=DGROUP _msg_vga_init: ; 0xc4800 LB 0x2f - db 'Oracle VM VirtualBox Version 4.3.36 VGA BIOS', 00dh, 00ah, 000h + db 'Oracle VM VirtualBox Version 4.3.40 VGA BIOS', 00dh, 00ah, 000h _vga_modes: ; 0xc482f LB 0x80 db 000h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 001h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h db 002h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h, 003h, 000h, 000h, 004h, 000h, 0b8h, 0ffh, 002h @@ -7667,7 +7667,7 @@ _vbebios_product_name: ; 0xc7e48 LB 0x21 db 'Oracle VM VirtualBox VBE Adapter', 000h _vbebios_product_revision: ; 0xc7e69 LB 0x24 - db 'Oracle VM VirtualBox Version 4.3.36', 000h + db 'Oracle VM VirtualBox Version 4.3.40', 000h _vbebios_info_string: ; 0xc7e8d LB 0x2b db 'VirtualBox VBE Display Adapter enabled', 00dh, 00ah, 00dh, 00ah, 000h _no_vbebios_info_string: ; 0xc7eb8 LB 0x29 @@ -7698,4 +7698,4 @@ db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h - db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 054h + db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 05eh diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.md5sum virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.md5sum --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.md5sum 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/BIOS/VBoxVgaBiosAlternative.md5sum 2016-08-22 14:19:26.000000000 +0000 @@ -1 +1 @@ -7959bedada4fa3a27a806ad7c721ac85 *VBoxVgaBios.rom +7f7b45646a87f6b5da7791e94e7d05d2 *VBoxVgaBios.rom diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp 2016-08-22 14:19:27.000000000 +0000 @@ -3661,7 +3661,7 @@ case SVGA3D_TRANSFORM_PROJECTION: { - int rc = ShaderTransformProjection(pContext->state.RectViewPort.w, pContext->state.RectViewPort.h, matrix); + int rc = ShaderTransformProjection(pContext->state.RectViewPort.w, pContext->state.RectViewPort.h, matrix, false /* fPretransformed */); AssertRCReturn(rc, rc); break; } @@ -5861,8 +5861,52 @@ return VINF_SUCCESS; } -int vmsvga3dDrawPrimitivesProcessVertexDecls(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl) +int vmsvga3dResetTransformMatrices(PVGASTATE pThis, PVMSVGA3DCONTEXT pContext) { + int rc; + + /* Reset the view matrix (also takes the world matrix into account). */ + if (pContext->state.aTransformState[SVGA3D_TRANSFORM_VIEW].fValid == true) + { + rc = vmsvga3dSetTransform(pThis, pContext->id, SVGA3D_TRANSFORM_VIEW, pContext->state.aTransformState[SVGA3D_TRANSFORM_VIEW].matrix); + } + else + { + float matrix[16]; + + /* identity matrix if no matrix set. */ + memset(matrix, 0, sizeof(matrix)); + matrix[0] = 1.0; + matrix[5] = 1.0; + matrix[10] = 1.0; + matrix[15] = 1.0; + rc = vmsvga3dSetTransform(pThis, pContext->id, SVGA3D_TRANSFORM_VIEW, matrix); + } + + /* Reset the projection matrix. */ + if (pContext->state.aTransformState[SVGA3D_TRANSFORM_PROJECTION].fValid == true) + { + rc = vmsvga3dSetTransform(pThis, pContext->id, SVGA3D_TRANSFORM_PROJECTION, pContext->state.aTransformState[SVGA3D_TRANSFORM_PROJECTION].matrix); + } + else + { + float matrix[16]; + + /* identity matrix if no matrix set. */ + memset(matrix, 0, sizeof(matrix)); + matrix[0] = 1.0; + matrix[5] = 1.0; + matrix[10] = 1.0; + matrix[15] = 1.0; + rc = vmsvga3dSetTransform(pThis, pContext->id, SVGA3D_TRANSFORM_PROJECTION, matrix); + } + AssertRC(rc); + return rc; +} + +int vmsvga3dDrawPrimitivesProcessVertexDecls(PVGASTATE pThis, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl) +{ + PVMSVGA3DSTATE pState = pThis->svga.p3dState; unsigned sidVertex = pVertexDecl[0].array.surfaceId; PVMSVGA3DSURFACE pVertexSurface; @@ -5935,13 +5979,16 @@ /* Use the predefined selection of vertex streams for the fixed pipeline. */ switch (pVertexDecl[iVertex].identity.usage) { + case SVGA3D_DECLUSAGE_POSITIONT: case SVGA3D_DECLUSAGE_POSITION: + { glEnableClientState(GL_VERTEX_ARRAY); VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); glVertexPointer(size, type, pVertexDecl[iVertex].array.stride, (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); break; + } case SVGA3D_DECLUSAGE_BLENDWEIGHT: AssertFailed(); break; @@ -5980,9 +6027,6 @@ case SVGA3D_DECLUSAGE_TESSFACTOR: AssertFailed(); break; - case SVGA3D_DECLUSAGE_POSITIONT: - AssertFailed(); /* see position_transformed in Wine */ - break; case SVGA3D_DECLUSAGE_COLOR: /** @todo color component order not identical!! test GL_BGRA!! */ glEnableClientState(GL_COLOR_ARRAY); VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); @@ -6016,11 +6060,20 @@ return VINF_SUCCESS; } -int vmsvga3dDrawPrimitivesCleanupVertexDecls(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl) +int vmsvga3dDrawPrimitivesCleanupVertexDecls(PVGASTATE pThis, PVMSVGA3DCONTEXT pContext, uint32_t iVertexDeclBase, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl) { - /* Setup the vertex declarations. */ + PVMSVGA3DSTATE pState = pThis->svga.p3dState; + + /* Clean up the vertex declarations. */ for (unsigned iVertex = 0; iVertex < numVertexDecls; iVertex++) { + if (pVertexDecl[iVertex].identity.usage == SVGA3D_DECLUSAGE_POSITIONT) + { + /* Reset the transformation matrices in case of a switch back from pretransformed mode. */ + Log(("vmsvga3dDrawPrimitivesCleanupVertexDecls: reset world and projection matrices after transformation reset (pre-transformed -> transformed)\n")); + vmsvga3dResetTransformMatrices(pThis, pContext); + } + if (pContext->state.shidVertex != SVGA_ID_INVALID) { /* Use numbered vertex arrays when shaders are active. */ @@ -6033,6 +6086,7 @@ switch (pVertexDecl[iVertex].identity.usage) { case SVGA3D_DECLUSAGE_POSITION: + case SVGA3D_DECLUSAGE_POSITIONT: glDisableClientState(GL_VERTEX_ARRAY); VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); break; @@ -6062,8 +6116,6 @@ break; case SVGA3D_DECLUSAGE_TESSFACTOR: break; - case SVGA3D_DECLUSAGE_POSITIONT: - break; case SVGA3D_DECLUSAGE_COLOR: /** @todo color component order not identical!! */ glDisableClientState(GL_COLOR_ARRAY); VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); @@ -6088,8 +6140,8 @@ int vmsvga3dDrawPrimitives(PVGASTATE pThis, uint32_t cid, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl, uint32_t numRanges, SVGA3dPrimitiveRange *pRange, uint32_t cVertexDivisor, SVGA3dVertexDivisor *pVertexDivisor) { - PVMSVGA3DCONTEXT pContext; PVMSVGA3DSTATE pState = pThis->svga.p3dState; + PVMSVGA3DCONTEXT pContext; AssertReturn(pState, VERR_INTERNAL_ERROR); int rc = VERR_NOT_IMPLEMENTED; uint32_t iCurrentVertex; @@ -6111,7 +6163,21 @@ pContext = pState->papContexts[cid]; VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); - /* Flush any shader changes. */ + /* Check for pretransformed vertex declarations. */ + for (unsigned iVertex = 0; iVertex < numVertexDecls; iVertex++) + { + switch (pVertexDecl[iVertex].identity.usage) + { + case SVGA3D_DECLUSAGE_POSITIONT: + Log(("ShaderSetPositionTransformed: (%d,%d)\n", pContext->state.RectViewPort.w, pContext->state.RectViewPort.h)); + case SVGA3D_DECLUSAGE_POSITION: + ShaderSetPositionTransformed(pContext->pShaderContext, pContext->state.RectViewPort.w, pContext->state.RectViewPort.h, + pVertexDecl[iVertex].identity.usage == SVGA3D_DECLUSAGE_POSITIONT); + break; + } + } + + /* Flush any shader changes; after (!) checking the vertex declarations to deal with pre-transformed vertices. */ if (pContext->pShaderContext) { uint32_t rtHeight = 0; @@ -6141,7 +6207,7 @@ sidVertex = pVertexDecl[iVertex].array.surfaceId; } - rc = vmsvga3dDrawPrimitivesProcessVertexDecls(pState, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]); + rc = vmsvga3dDrawPrimitivesProcessVertexDecls(pThis, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]); AssertRCReturn(rc, rc); iCurrentVertex = iVertex; @@ -6222,20 +6288,37 @@ } else { + GLenum indexType; + Assert(pRange[iPrimitive].indexBias >= 0); /** @todo indexBias */ Assert(pRange[iPrimitive].indexWidth == pRange[iPrimitive].indexArray.stride); + if (pRange[iPrimitive].indexWidth == sizeof(uint8_t)) + { + indexType = GL_UNSIGNED_BYTE; + } + else + if (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) + { + indexType = GL_UNSIGNED_SHORT; + } + else + { + Assert(pRange[iPrimitive].indexWidth == sizeof(uint32_t)); + indexType = GL_UNSIGNED_INT; + } + /* Render with an index buffer */ Log(("DrawIndexedPrimitive %x cPrimitives=%d cVertices=%d hint.first=%d hint.last=%d index offset=%d primitivecount=%d index width=%d index bias=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pVertexDecl[0].rangeHint.first, pVertexDecl[0].rangeHint.last, pRange[iPrimitive].indexArray.offset, pRange[iPrimitive].primitiveCount, pRange[iPrimitive].indexWidth, pRange[iPrimitive].indexBias)); if (pRange[iPrimitive].indexBias == 0) glDrawElements(modeDraw, cVertices, - (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, + indexType, (GLvoid *)(uintptr_t)pRange[iPrimitive].indexArray.offset); /* byte offset in indices buffer */ else pState->ext.glDrawElementsBaseVertex(modeDraw, cVertices, - (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, + indexType, (GLvoid *)(uintptr_t)pRange[iPrimitive].indexArray.offset, /* byte offset in indices buffer */ pRange[iPrimitive].indexBias); /* basevertex */ @@ -6264,7 +6347,7 @@ sidVertex = pVertexDecl[iVertex].array.surfaceId; } - rc = vmsvga3dDrawPrimitivesCleanupVertexDecls(pState, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]); + rc = vmsvga3dDrawPrimitivesCleanupVertexDecls(pThis, pContext, iCurrentVertex, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex]); AssertRCReturn(rc, rc); iCurrentVertex = iVertex; @@ -6307,16 +6390,17 @@ #endif #ifdef DEBUG_GFX_WINDOW - if (pContext->aSidActiveTexture[0]) + if (pContext->sidRenderTarget) { SVGA3dCopyRect rect; rect.srcx = rect.srcy = rect.x = rect.y = 0; - rect.w = 800; - rect.h = 600; + rect.w = pContext->state.RectViewPort.w; + rect.h = pContext->state.RectViewPort.h; vmsvga3dCommandPresent(pThis, pContext->sidRenderTarget, 0, NULL); } #endif + return rc; } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp 2016-08-22 14:19:26.000000000 +0000 @@ -2343,6 +2343,7 @@ /* * Insufficient, must wait for it to arrive. */ +/** @todo Should clear the busy flag here to maybe encourage the guest to wake us up. */ STAM_REL_PROFILE_START(&pSVGAState->StatFifoStalls, Stall); for (uint32_t i = 0;; i++) { @@ -2427,7 +2428,7 @@ /* - * Signal the semaphore to make sure we don't wait for 250 after a + * Signal the semaphore to make sure we don't wait for 250ms after a * suspend & resume scenario (see vmsvgaFIFOGetCmdPayload). */ SUPSemEventSignal(pThis->svga.pSupDrvSession, pThis->svga.FIFORequestSem); @@ -2439,7 +2440,25 @@ uint8_t *pbBounceBuf = (uint8_t *)RTMemAllocZ(VMSVGA_FIFO_SIZE); AssertReturn(pbBounceBuf, VERR_NO_MEMORY); + /* + * Polling/sleep interval config. + * + * We wait for an a short interval if the guest has recently given us work + * to do, but the interval increases the longer we're kept idle. With the + * current parameters we'll be at a 64ms poll interval after 1 idle second, + * at 90ms after 2 seconds, and reach the max 250ms interval after about + * 16 seconds. + */ + RTMSINTERVAL const cMsMinSleep = 16; + RTMSINTERVAL const cMsIncSleep = 2; + RTMSINTERVAL const cMsMaxSleep = 250; + RTMSINTERVAL cMsSleep = cMsMaxSleep; + + /* + * The FIFO loop. + */ LogFlow(("vmsvgaFIFOLoop: started loop\n")); + bool fBadOrDisabledFifo = false; uint32_t volatile * const pFIFO = pThis->svga.pFIFOR3; while (pThread->enmState == PDMTHREADSTATE_RUNNING) { @@ -2452,25 +2471,37 @@ # endif /* - * Wait for at most 250 ms to start polling. + * Unless there's already work pending, go to sleep for a short while. + * (See polling/sleep interval config above.) */ - rc = SUPSemEventWaitNoResume(pThis->svga.pSupDrvSession, pThis->svga.FIFORequestSem, 250); - AssertBreak(RT_SUCCESS(rc) || rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED); - if (pThread->enmState != PDMTHREADSTATE_RUNNING) + if ( fBadOrDisabledFifo + || pFIFO[SVGA_FIFO_NEXT_CMD] == pFIFO[SVGA_FIFO_STOP]) { - LogFlow(("vmsvgaFIFOLoop: thread state %x\n", pThread->enmState)); - break; + rc = SUPSemEventWaitNoResume(pThis->svga.pSupDrvSession, pThis->svga.FIFORequestSem, cMsSleep); + AssertBreak(RT_SUCCESS(rc) || rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED); + if (pThread->enmState != PDMTHREADSTATE_RUNNING) + { + LogFlow(("vmsvgaFIFOLoop: thread state %x\n", pThread->enmState)); + break; + } } + else + rc = VINF_SUCCESS; + fBadOrDisabledFifo = false; if (rc == VERR_TIMEOUT) { if (pFIFO[SVGA_FIFO_NEXT_CMD] == pFIFO[SVGA_FIFO_STOP]) + { + cMsSleep = RT_MIN(cMsSleep + cMsIncSleep, cMsMaxSleep); continue; + } STAM_REL_COUNTER_INC(&pSVGAState->StatFifoTodoTimeout); Log(("vmsvgaFIFOLoop: timeout\n")); } else if (pFIFO[SVGA_FIFO_NEXT_CMD] != pFIFO[SVGA_FIFO_STOP]) STAM_REL_COUNTER_INC(&pSVGAState->StatFifoTodoWoken); + cMsSleep = cMsMinSleep; Log(("vmsvgaFIFOLoop: enabled=%d configured=%d busy=%d\n", pThis->svga.fEnabled, pThis->svga.fConfigured, pThis->svga.pFIFOR3[SVGA_FIFO_BUSY])); Log(("vmsvgaFIFOLoop: min %x max %x\n", pFIFO[SVGA_FIFO_MIN], pFIFO[SVGA_FIFO_MAX])); @@ -2492,6 +2523,7 @@ || !pThis->svga.fConfigured) { vmsvgaFifoSetNotBusy(pThis, pSVGAState, pFIFO[SVGA_FIFO_MIN]); + fBadOrDisabledFifo = true; continue; } @@ -2515,6 +2547,7 @@ STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors); LogRelMax(8, ("vmsvgaFIFOLoop: Bad fifo: min=%#x stop=%#x max=%#x\n", offFifoMin, offCurrentCmd, offFifoMax)); vmsvgaFifoSetNotBusy(pThis, pSVGAState, offFifoMin); + fBadOrDisabledFifo = true; continue; } if (RT_UNLIKELY(offCurrentCmd & 3)) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c 2016-08-22 14:19:27.000000000 +0000 @@ -4261,6 +4261,36 @@ return ret; } +#ifdef VBOX_WITH_VMSVGA +static GLhandleARB generate_passthrough_vshader(const struct wined3d_gl_info *gl_info) +{ + GLhandleARB ret = 0; + static const char *passthrough_vshader[] = + { + "#version 120\n" + "vec4 R0;\n" + "void main(void)\n" + "{\n" + " R0 = gl_Vertex;\n" + " R0.w = 1.0;\n" + " R0.z = 0.0;\n" + " gl_Position = gl_ModelViewProjectionMatrix * R0;\n" + "}\n" + }; + + ret = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)); + checkGLcall("glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)"); + GL_EXTCALL(glShaderSourceARB(ret, 1, passthrough_vshader, NULL)); + checkGLcall("glShaderSourceARB(ret, 1, passthrough_vshader, NULL)"); + GL_EXTCALL(glCompileShaderARB(ret)); + checkGLcall("glCompileShaderARB(ret)"); + shader_glsl_validate_compile_link(gl_info, ret, FALSE); + + return ret; +} + +#endif + /* GL locking is done by the caller */ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info, GLhandleARB programId, char prefix) @@ -4709,6 +4739,23 @@ list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); } +#ifdef VBOX_WITH_VMSVGA + else + if (device->strided_streams.position_transformed) + { + GLhandleARB passthrough_vshader_id; + + passthrough_vshader_id = generate_passthrough_vshader(gl_info); + TRACE("Attaching GLSL shader object %p to program %p\n", (void *)(uintptr_t)passthrough_vshader_id, (void *)(uintptr_t)programId); + GL_EXTCALL(glAttachObjectARB(programId, passthrough_vshader_id)); + checkGLcall("glAttachObjectARB"); + /* Flag the reorder function for deletion, then it will be freed automatically when the program + * is destroyed + */ + GL_EXTCALL(glDeleteObjectARB(passthrough_vshader_id)); + } +#endif + /* Attach GLSL pshader */ if (pshader) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderapi.c virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderapi.c --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderapi.c 2016-01-19 19:17:48.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderapi.c 2016-08-22 14:19:27.000000000 +0000 @@ -14,7 +14,6 @@ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ - #include #include #include @@ -625,6 +624,35 @@ return VINF_SUCCESS; } +SHADERDECL(int) ShaderSetPositionTransformed(void *pShaderContext, unsigned cxViewPort, unsigned cyViewPort, bool fPreTransformed) +{ + IWineD3DDeviceImpl *This; + int rc; + + SHADER_SET_CURRENT_CONTEXT(pShaderContext); + This = g_pCurrentContext->pDeviceContext; + + if (This->strided_streams.position_transformed == fPreTransformed) + return VINF_SUCCESS; /* no changes; nothing to do. */ + + Log(("ShaderSetPositionTransformed viewport (%d,%d) fPreTransformed=%d\n", cxViewPort, cyViewPort, fPreTransformed)); + + if (fPreTransformed) + { /* In the pre-transformed vertex coordinate case we need to disable all transformations as we're already using screen coordinates. */ + /* Load the identity matrix for the model view */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + /* Reset the projection matrix too */ + rc = ShaderTransformProjection(cxViewPort, cyViewPort, NULL, fPreTransformed); + AssertRCReturn(rc, rc); + } + + This->strided_streams.position_transformed = fPreTransformed; + ((IWineD3DVertexDeclarationImpl *)(This->stateBlock->vertexDecl))->position_transformed = fPreTransformed; + return VINF_SUCCESS; +} + SHADERDECL(int) ShaderUpdateState(void *pShaderContext, uint32_t rtHeight) { IWineD3DDeviceImpl *pThis; @@ -667,7 +695,7 @@ return VINF_SUCCESS; } -SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16]) +SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16], bool fPretransformed) { #ifdef DEBUG GLenum lastError; @@ -722,11 +750,20 @@ yoffset = -(63.0f / 64.0f) / cyViewPort; glTranslatef(xoffset, -yoffset, -1.0f); - /* flip y coordinate origin too */ - glScalef(1.0f, -1.0f, 2.0f); - glMultMatrixf(matrix); + if (fPretransformed) + { + /* One world coordinate equals one screen pixel; y-inversion no longer an issue */ + glOrtho(0, cxViewPort, 0, cyViewPort, -1, 1); + } + else + { + /* flip y coordinate origin too */ + glScalef(1.0f, -1.0f, 2.0f); + /* Apply the supplied projection matrix */ + glMultMatrixf(matrix); + } #ifdef DEBUG lastError = glGetError(); \ AssertMsgReturn(lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, lastError), VERR_INTERNAL_ERROR); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderlib.h virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderlib.h --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderlib.h 2016-01-19 19:17:48.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/shaderlib/shaderlib.h 2016-08-22 14:19:27.000000000 +0000 @@ -86,9 +86,11 @@ SHADERDECL(int) ShaderSetPixelShaderConstantI(void *pShaderContext, uint32_t reg, const int32_t *pValues, uint32_t cRegisters); SHADERDECL(int) ShaderSetPixelShaderConstantF(void *pShaderContext, uint32_t reg, const float *pValues, uint32_t cRegisters); +SHADERDECL(int) ShaderSetPositionTransformed(void *pShaderContext, unsigned cxViewPort, unsigned cyViewPort, bool fPreTransformed); + SHADERDECL(int) ShaderUpdateState(void *pShaderContext, uint32_t rtHeight); -SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16]); +SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16], bool fPretransformed); RT_C_DECLS_END diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/VBoxSVGA3D.def virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/VBoxSVGA3D.def --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Graphics/VBoxSVGA3D.def 2016-01-19 19:17:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Graphics/VBoxSVGA3D.def 2016-08-22 14:19:27.000000000 +0000 @@ -35,4 +35,6 @@ ShaderSetPixelShaderConstantF ShaderUpdateState ShaderTransformProjection + ShaderSetPositionTransformed + diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/Network/DevEEPROM.cpp virtualbox-4.3.40-dfsg/src/VBox/Devices/Network/DevEEPROM.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Devices/Network/DevEEPROM.cpp 2016-01-19 19:17:58.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/Network/DevEEPROM.cpp 2016-08-22 14:19:40.000000000 +0000 @@ -85,8 +85,9 @@ */ EEPROM93C46::State EEPROM93C46::opRead() { - m_u16Word = m_au16Data[m_u16Addr++]; - E1kLog(("EEPROM: Reading word %04x at %08x\n", m_u16Word, m_u16Addr-1)); + m_u16Word = m_au16Data[m_u16Addr]; + E1kLog(("EEPROM: Reading word %04x at %08x\n", m_u16Word, m_u16Addr)); + m_u16Addr = (m_u16Addr + 1) & ADDR_MASK; m_u16Mask = DATA_MSB; return WRITING_DO; } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/system.c virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/system.c --- virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/system.c 2016-01-19 19:18:04.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/system.c 2016-08-22 14:19:50.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2013 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -355,7 +355,7 @@ break; case 0x83: { - if( GET_AL() ) { + if( GET_AL() == 0 ) { // Set Interval requested. if( ( read_byte( 0x40, 0xA0 ) & 1 ) == 0 ) { // Interval not already set. diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.asm virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.asm --- virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.asm 2016-01-19 19:18:04.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.asm 2016-08-22 14:19:49.000000000 +0000 @@ -403,7 +403,7 @@ ; Source file: system.c ; ; -; Copyright (C) 2006-2013 Oracle Corporation +; Copyright (C) 2006-2016 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; @@ -965,7 +965,7 @@ section CONST2 progbits vstart=0xda8 align=1 ; size=0x3fa class=DATA group=DGROUP _bios_cvs_version_string: ; 0xf0da8 LB 0x12 - db 'VirtualBox 4.3.36', 000h + db 'VirtualBox 4.3.40', 000h _bios_prefix_string: ; 0xf0dba LB 0x8 db 'BIOS: ', 000h, 000h _isotag: ; 0xf0dc2 LB 0x6 @@ -8525,7 +8525,7 @@ mov word [bp+018h], cx ; 89 4e 18 jmp short 05fc3h ; eb e6 test byte [bp+012h], 0ffh ; f6 46 12 ff - je short 0604fh ; 74 6c + jne short 0604fh ; 75 6c mov dx, 000a0h ; ba a0 00 mov ax, strict word 00040h ; b8 40 00 call 01600h ; e8 14 b6 @@ -16070,4 +16070,4 @@ db 'XM' cpu_reset: ; 0xffff0 LB 0x10 jmp far 0f000h:0e05bh ; ea 5b e0 00 f0 - db 030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 0fch + db 030h, 036h, 02fh, 032h, 033h, 02fh, 039h, 039h, 000h, 0fch, 000h diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.md5sum virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.md5sum --- virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.md5sum 2016-01-19 19:18:04.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative.md5sum 2016-08-22 14:19:49.000000000 +0000 @@ -1 +1 @@ -3e7ca7deef30df22fe0d644c2bef3c45 *VBoxPcBios.rom +1ccbaec3da69b3361b4a4a3588679b5a *VBoxPcBios.rom diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/DevAPIC.cpp virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/DevAPIC.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Devices/PC/DevAPIC.cpp 2016-01-19 19:18:05.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Devices/PC/DevAPIC.cpp 2016-08-22 14:19:50.000000000 +0000 @@ -1912,7 +1912,7 @@ { uint64_t u64; - pHlp->pfnPrintf(pHlp, "Local APIC at %08llx:\n", pApic->apicbase); + pHlp->pfnPrintf(pHlp, "CPU%u: Local APIC at %08llx:\n", pApic->phys_id, pApic->apicbase); u64 = apicR3InfoReadReg(pDev, pApic, 0x2); pHlp->pfnPrintf(pHlp, " LAPIC ID : %08llx\n", u64); pHlp->pfnPrintf(pHlp, " APIC ID = %02llx\n", (u64 >> 24) & 0xff); @@ -2014,7 +2014,11 @@ static DECLCALLBACK(void) apicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { APICDeviceInfo *pDev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *); - APICState *pApic = apicGetStateByCurEmt(pDev); + PVM pVM = PDMDevHlpGetVM(pDevIns); + VMCPUID idCpu = VMMGetCpuId(pVM); + if (idCpu == NIL_VMCPUID) /* Don't crash if we're not on EMT, just assume EMT0 for now. */ + idCpu = 0; + APICState *pApic = apicGetStateById(pDev, idCpu); if (pszArgs == NULL || !*pszArgs || !strcmp(pszArgs, "basic")) apicR3InfoBasic(pDev, pApic, pHlp); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp virtualbox-4.3.40-dfsg/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp 2016-01-19 19:18:23.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp 2016-08-22 14:20:11.000000000 +0000 @@ -606,7 +606,7 @@ CHECK_ERROR(progress, COMGETTER(ResultCode)(&iRc)); if (SUCCEEDED(rc)) { - if (SUCCEEDED(rc)) + if (SUCCEEDED(iRc)) RTPrintf("VM \"%s\" has been successfully started.\n", pszVM); else { diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts virtualbox-4.3.40-dfsg/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts --- virtualbox-4.3.36-dfsg/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts 2016-01-19 19:18:26.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts 2016-08-22 14:20:13.000000000 +0000 @@ -860,7 +860,7 @@ Gro&up - Gr*up + Gr&up Sort the group of the first selected machine alphabetically @@ -934,7 +934,7 @@ Network - Jaringan + Jaringan @@ -2718,15 +2718,15 @@ Machine Windows: - + Jendela Mesin: If checked, machine windows will be raised when the mouse pointer moves over them. - + Bila dicontreng, jendela mesin akan diapungkan ketika penunjuk mouse bergerak di atas mereka. &Raise Window Under Mouse - + &Apungkan Jendela Di Bawah Mouse @@ -2788,7 +2788,7 @@ Holds the path to the library that provides authentication for Remote Display (VRDP) clients. - Menyimpan path ke pustaka yang menyediakan otentikasi untuk klien Tampilan Jarak Jauh (VRDP). + Menyimpan path ke pustaka yang menyediakan otentikasi untuk klien Tampilan Jarak Jauh (VRDP). Default &Machine Folder: @@ -4141,11 +4141,11 @@ Connect Network Adapter - + Sambungkan Adaptor Jaringan Connect Network Adapter %1 - + Sambungkan Adaptor Jaringan %1 @@ -4422,7 +4422,7 @@ Remote Display is currently enabled for this virtual machine. However, this requires the <b>%1</b> to be installed. Please install the Extension Pack from the VirtualBox download site as otherwise your VM will be started with Remote Display disabled. - + Tampilan Jarak Jauh saat ini difungsikan bagi mesin virtual ini. Namun ini memerlukan dipasangnya <i>%1</i>. Harap pasang Extension Pack dari situs unduh VirtualBox karena bila tidak VM Anda akan mulai dijalankan dengan Tampilan Jarak Jauh dinonaktifkan. @@ -9305,7 +9305,7 @@ &Full clone - Klon penuh + Klon &penuh &Linked clone diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/linux/Makefile virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/linux/Makefile --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/linux/Makefile 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/linux/Makefile 2016-08-22 14:20:21.000000000 +0000 @@ -290,13 +290,13 @@ install: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ + install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; \ rm -f /etc/vbox/module_not_compiled install_rpm: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) + install -m 0644 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) else # eq ($(MAKECMDGOALS),clean) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/SUPDrv.c virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/SUPDrv.c --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/SUPDrv.c 2016-01-19 19:18:36.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/SUPDrv.c 2016-08-22 14:20:21.000000000 +0000 @@ -2953,7 +2953,7 @@ * Let IPRT do the job. */ Mem.eType = MEMREF_TYPE_LOCKED; - rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb, RTMEM_PROT_READ | RTMEM_PROT_WRITE, RTR0ProcHandleSelf()); + rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb, RTMEM_PROT_READ | RTMEM_PROT_WRITE, NIL_RTR0PROCESS); if (RT_SUCCESS(rc)) { uint32_t iPage = cPages; @@ -3040,7 +3040,7 @@ { int rc2; rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (RTR3PTR)-1, 0, - RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf()); + RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, NIL_RTR0PROCESS); if (RT_SUCCESS(rc)) { Mem.eType = MEMREF_TYPE_CONT; @@ -3123,7 +3123,7 @@ { int rc2; rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (RTR3PTR)-1, 0, - RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf()); + RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, NIL_RTR0PROCESS); if (RT_SUCCESS(rc)) { Mem.eType = MEMREF_TYPE_LOW; @@ -3204,7 +3204,7 @@ { int rc2; rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (RTR3PTR)-1, 0, - RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf()); + RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, NIL_RTR0PROCESS); if (RT_SUCCESS(rc)) { Mem.eType = MEMREF_TYPE_MEM; @@ -3349,7 +3349,7 @@ int rc2; if (ppvR3) rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (RTR3PTR)-1, 0, - RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf()); + RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, NIL_RTR0PROCESS); else Mem.MapObjR3 = NIL_RTR0MEMOBJ; if (RT_SUCCESS(rc)) @@ -4067,7 +4067,7 @@ { if (pSession->GipMapObjR3 == NIL_RTR0MEMOBJ) rc = RTR0MemObjMapUser(&pSession->GipMapObjR3, pDevExt->GipMemObj, (RTR3PTR)-1, 0, - RTMEM_PROT_READ, RTR0ProcHandleSelf()); + RTMEM_PROT_READ, NIL_RTR0PROCESS); if (RT_SUCCESS(rc)) pGipR3 = RTR0MemObjAddressR3(pSession->GipMapObjR3); } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/SUPLibInternal.h virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/SUPLibInternal.h --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/SUPLibInternal.h 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/SUPLibInternal.h 2016-08-22 14:20:21.000000000 +0000 @@ -315,7 +315,8 @@ SUPR3HARDENEDMAINSTATE_NOT_YET_CALLED = 0, SUPR3HARDENEDMAINSTATE_WIN_EARLY_INIT_CALLED, SUPR3HARDENEDMAINSTATE_WIN_EARLY_IMPORTS_RESOLVED, - SUPR3HARDENEDMAINSTATE_WIN_EARLY_DEVICE_OPENED, + SUPR3HARDENEDMAINSTATE_WIN_EARLY_STUB_DEVICE_OPENED, + SUPR3HARDENEDMAINSTATE_WIN_EARLY_REAL_DEVICE_OPENED, SUPR3HARDENEDMAINSTATE_WIN_EP_CALLED, SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED, SUPR3HARDENEDMAINSTATE_WIN_VERSION_INITIALIZED, @@ -446,7 +447,7 @@ #ifdef RT_OS_WINDOWS DECLHIDDEN(void) supR3HardenedWinInit(uint32_t fFlags, bool fAvastKludge); -DECLHIDDEN(void) supR3HardenedWinInitVersion(void); +DECLHIDDEN(void) supR3HardenedWinInitVersion(bool fEarlyInit); DECLHIDDEN(void) supR3HardenedWinInitImports(void); # ifdef ___iprt_nt_nt_h___ DECLHIDDEN(void) supR3HardenedWinGetVeryEarlyImports(uintptr_t uNtDllAddr, @@ -454,7 +455,7 @@ PFNNTSETEVENT *ppfnNtSetEvent); # endif DECLHIDDEN(void) supR3HardenedWinInitImportsEarly(uintptr_t uNtDllAddr); -DECLHIDDEN(void) supR3HardenedWinInitSyscalls(bool fReportErrors); +DECLHIDDEN(void) supR3HardenedWinInitSyscalls(bool fReportErrors, PRTERRINFO pErrInfo); DECLHIDDEN(PFNRT) supR3HardenedWinGetRealDllSymbol(const char *pszDll, const char *pszProcedure); DECLHIDDEN(void) supR3HardenedWinEnableThreadCreation(void); DECLHIDDEN(void) supR3HardenedWinResolveVerifyTrustApiAndHookThreadCreation(const char *pszProgName); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp 2016-08-22 14:20:22.000000000 +0000 @@ -2768,24 +2768,28 @@ * Initializes g_uNtVerCombined and g_NtVerInfo. * Called from suplibHardenedWindowsMain and suplibOsInit. */ -DECLHIDDEN(void) supR3HardenedWinInitVersion(void) +DECLHIDDEN(void) supR3HardenedWinInitVersion(bool fEarly) { /* * Get the windows version. Use RtlGetVersion as GetVersionExW and * GetVersion might not be telling the whole truth (8.0 on 8.1 depending on * the application manifest). + * + * Note! Windows 10 build 14267+ touches BSS when calling RtlGetVersion, so we + * have to use the fallback for the call from the early init code. */ OSVERSIONINFOEXW NtVerInfo; RT_ZERO(NtVerInfo); NtVerInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&NtVerInfo))) + if ( fEarly + || !NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&NtVerInfo))) { RT_ZERO(NtVerInfo); PPEB pPeb = NtCurrentPeb(); NtVerInfo.dwMajorVersion = pPeb->OSMajorVersion; NtVerInfo.dwMinorVersion = pPeb->OSMinorVersion; - NtVerInfo.dwBuildNumber = pPeb->OSPlatformId; + NtVerInfo.dwBuildNumber = pPeb->OSBuildNumber; } g_uNtVerCombined = SUP_MAKE_NT_VER_COMBINED(NtVerInfo.dwMajorVersion, NtVerInfo.dwMinorVersion, NtVerInfo.dwBuildNumber, diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp 2016-08-22 14:20:22.000000000 +0000 @@ -276,6 +276,37 @@ /** + * Adds error information. + * + * @returns @a rc. + * @param pErrInfo Pointer to the extended error info structure + * which may contain some details already. Can be + * NULL. + * @param rc The status to return. + * @param pszMsg The format string for the message. + * @param ... The arguments for the format string. + */ +static int supHardNtVpAddInfo1(PRTERRINFO pErrInfo, int rc, const char *pszMsg, ...) +{ + va_list va; +#ifdef IN_RING3 + va_start(va, pszMsg); + if (pErrInfo && pErrInfo->pszMsg) + supR3HardenedError(rc, false /*fFatal*/, "%N - %s\n", pszMsg, &va, pErrInfo->pszMsg); + else + supR3HardenedError(rc, false /*fFatal*/, "%N\n", pszMsg, &va); + va_end(va); +#endif + + va_start(va, pszMsg); + RTErrInfoAddV(pErrInfo, rc, pszMsg, va); + va_end(va); + + return rc; +} + + +/** * Fills in error information. * * @returns @a rc. @@ -1559,7 +1590,7 @@ NTSTATUS rcNt; /* - * Try figure if the entire allocation size. Free/Alloc may fail otherwise. + * Try figure the entire allocation size. Free/Alloc may fail otherwise. */ PVOID pvFree = pMemInfo->AllocationBase; SIZE_T cbFree = pMemInfo->RegionSize + ((uintptr_t)pMemInfo->BaseAddress - (uintptr_t)pMemInfo->AllocationBase); @@ -1578,6 +1609,9 @@ break; if (pMemInfo->AllocationBase != MemInfo2.AllocationBase) break; + if (MemInfo2.RegionSize == 0) + break; + cbFree += MemInfo2.RegionSize; } SUP_DPRINTF(("supHardNtVpFreeOrReplacePrivateExecMemory: %s exec mem at %p (LB %#zx, %p LB %#zx)\n", pThis->fFlags & SUPHARDNTVP_F_EXEC_ALLOC_REPLACE_WITH_RW ? "Replacing" : "Freeing", @@ -2194,7 +2228,7 @@ enmArch = RTLDRARCH_WHATEVER; rc = RTLdrOpenWithReader(&pNtViRdr->Core, RTLDR_O_FOR_VALIDATION, enmArch, &hLdrMod, pErrInfo); if (RT_FAILURE(rc)) - return supHardNtVpSetInfo1(pErrInfo, rc, "RTLdrOpenWithReader failed: %Rrc (Image='%ls').", + return supHardNtVpAddInfo1(pErrInfo, rc, "RTLdrOpenWithReader failed: %Rrc (Image='%ls').", rc, pUniStrPath->Buffer); /* @@ -2231,8 +2265,10 @@ * @param pszName The DLL name. Must be one from the * g_apszSupNtVpAllowedDlls array. * @param ppEntry Where to return the entry we've opened/found. + * @param pErrInfo Optional buffer where to return additional error + * information. */ -DECLHIDDEN(int) supHardNtLdrCacheOpen(const char *pszName, PSUPHNTLDRCACHEENTRY *ppEntry) +DECLHIDDEN(int) supHardNtLdrCacheOpen(const char *pszName, PSUPHNTLDRCACHEENTRY *ppEntry, PRTERRINFO pErrInfo) { /* * Locate the dll. @@ -2270,7 +2306,7 @@ UniStr.MaximumLength = UniStr.Length + sizeof(WCHAR); int rc = supHardNtLdrCacheNewEntry(&g_aSupNtVpLdrCacheEntries[g_cSupNtVpLdrCacheEntries], pszName, &UniStr, - true /*fDll*/, false /*f32bitResourceDll*/, NULL /*pErrInfo*/); + true /*fDll*/, false /*f32bitResourceDll*/, pErrInfo); if (RT_SUCCESS(rc)) { *ppEntry = &g_aSupNtVpLdrCacheEntries[g_cSupNtVpLdrCacheEntries]; diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h 2016-08-22 14:20:22.000000000 +0000 @@ -170,7 +170,7 @@ } SUPHNTLDRCACHEENTRY; /** Pointer to a loader cache entry. */ typedef SUPHNTLDRCACHEENTRY *PSUPHNTLDRCACHEENTRY; -DECLHIDDEN(int) supHardNtLdrCacheOpen(const char *pszName, PSUPHNTLDRCACHEENTRY *ppEntry); +DECLHIDDEN(int) supHardNtLdrCacheOpen(const char *pszName, PSUPHNTLDRCACHEENTRY *ppEntry, PRTERRINFO pErrInfo); DECLHIDDEN(int) supHardNtLdrCacheEntryVerify(PSUPHNTLDRCACHEENTRY pEntry, PCRTUTF16 pwszName, PRTERRINFO pErrInfo); DECLHIDDEN(int) supHardNtLdrCacheEntryGetBits(PSUPHNTLDRCACHEENTRY pEntry, uint8_t **ppbBits, RTLDRADDR uBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser, PRTERRINFO pErrInfo); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp 2016-08-22 14:20:22.000000000 +0000 @@ -90,7 +90,7 @@ if (!g_fHardenedVerifyInited) { #if defined(VBOX_WITH_HARDENING) && !defined(IN_SUP_HARDENED_R3) && !defined(IN_SUP_R3_STATIC) - supR3HardenedWinInitVersion(); + supR3HardenedWinInitVersion(false /*fEarly*/); int rc = supHardenedWinInitImageVerifier(NULL); if (RT_FAILURE(rc)) return rc; diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMainImports-win.cpp virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMainImports-win.cpp --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMainImports-win.cpp 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMainImports-win.cpp 2016-08-22 14:20:22.000000000 +0000 @@ -580,7 +580,7 @@ volatile uint8_t abCopy[16]; memcpy((void *)&abCopy[0], pbFunction, sizeof(abCopy)); SUPHNTIMP_ERROR(fReportErrors, 17, "supR3HardenedWinInitImports", kSupInitOp_Misc, rc, - "%ls: supHardNtLdrCacheOpen failed: '%s': %.16Rhxs", + "%ls: failed to parse syscall: '%s': %.16Rhxs", pDll->pwszName, pImport->pszName, &abCopy[0]); } @@ -593,19 +593,22 @@ * * @param fReportErrors Whether we've got the machinery for reporting * errors going already. + * @param pErrInfo Buffer for gathering additional error info. This + * is mainly to avoid consuming lots of stacks with + * RTERRINFOSTATIC structures. */ -DECLHIDDEN(void) supR3HardenedWinInitSyscalls(bool fReportErrors) +DECLHIDDEN(void) supR3HardenedWinInitSyscalls(bool fReportErrors, PRTERRINFO pErrInfo) { for (uint32_t iDll = 0; iDll < RT_ELEMENTS(g_aSupNtImpDlls); iDll++) if (g_aSupNtImpDlls[iDll].paSyscalls) { PSUPHNTLDRCACHEENTRY pLdrEntry; - int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry); + int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry, pErrInfo); if (RT_SUCCESS(rc)) { uint8_t *pbBits; - rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, (uintptr_t)g_aSupNtImpDlls[iDll].pbImageBase, NULL, NULL, - NULL /*pErrInfo*/); + rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, (uintptr_t)g_aSupNtImpDlls[iDll].pbImageBase, + NULL, NULL, pErrInfo); if (RT_SUCCESS(rc)) { for (uint32_t i = 0; i < g_aSupNtImpDlls[iDll].cImports; i++) @@ -614,11 +617,13 @@ } else SUPHNTIMP_ERROR(fReportErrors, 20, "supR3HardenedWinInitImports", kSupInitOp_Misc, rc, - "%ls: supHardNtLdrCacheEntryGetBits failed: %Rrc '%s'.", g_aSupNtImpDlls[iDll].pwszName, rc); + "%ls: supHardNtLdrCacheEntryGetBits failed: %Rrc %s", + g_aSupNtImpDlls[iDll].pwszName, rc, pErrInfo ? pErrInfo->pszMsg : ""); } else SUPHNTIMP_ERROR(fReportErrors, 21, "supR3HardenedWinInitImports", kSupInitOp_Misc, rc, - "%ls: supHardNtLdrCacheOpen failed: %Rrc '%s'.", g_aSupNtImpDlls[iDll].pwszName, rc); + "%ls: supHardNtLdrCacheOpen failed: %Rrc %s", + g_aSupNtImpDlls[iDll].pwszName, rc, pErrInfo ? pErrInfo->pszMsg : ""); } } @@ -652,12 +657,12 @@ }; for (uint32_t i = 0; i < RT_ELEMENTS(aImports); i++) - { - const char *pszForwarder = supR3HardenedResolveImport(&g_aSupNtImpDlls[0], &aImports[i], false); - if (pszForwarder) - SUPHNTIMP_ERROR(false, 31, "supR3HardenedWinGetVeryEarlyImports", kSupInitOp_Misc, VERR_MODULE_NOT_FOUND, - "ntdll: Failed to resolve forwarder '%s'.", pszForwarder); - } + { + const char *pszForwarder = supR3HardenedResolveImport(&g_aSupNtImpDlls[0], &aImports[i], false); + if (pszForwarder) + SUPHNTIMP_ERROR(false, 31, "supR3HardenedWinGetVeryEarlyImports", kSupInitOp_Misc, VERR_MODULE_NOT_FOUND, + "ntdll: Failed to resolve forwarder '%s'.", pszForwarder); + } /* * Restore the NtDll entry. @@ -712,6 +717,8 @@ */ DECLHIDDEN(void) supR3HardenedWinInitImports(void) { + RTERRINFOSTATIC ErrInfo; + /* * Find the DLLs we will be needing first (forwarders). */ @@ -749,7 +756,7 @@ /* * Do system calls directly. */ - supR3HardenedWinInitSyscalls(false); + supR3HardenedWinInitSyscalls(false, RTErrInfoInitStatic(&ErrInfo)); /* * Use the on disk image to avoid export table patching. Currently @@ -759,12 +766,12 @@ if (g_aSupNtImpDlls[iDll].cPatchedExports > 0) { PSUPHNTLDRCACHEENTRY pLdrEntry; - int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry); + int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry, RTErrInfoInitStatic(&ErrInfo)); if (RT_SUCCESS(rc)) { uint8_t *pbBits; rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, (uintptr_t)g_aSupNtImpDlls[iDll].pbImageBase, NULL, NULL, - NULL /*pErrInfo*/); + RTErrInfoInitStatic(&ErrInfo)); if (RT_SUCCESS(rc)) for (uint32_t i = 0; i < g_aSupNtImpDlls[iDll].cImports; i++) { @@ -796,6 +803,8 @@ */ DECLHIDDEN(PFNRT) supR3HardenedWinGetRealDllSymbol(const char *pszDll, const char *pszProcedure) { + RTERRINFOSTATIC ErrInfo; + /* * Look the DLL up in the import DLL table. */ @@ -804,12 +813,12 @@ { PSUPHNTLDRCACHEENTRY pLdrEntry; - int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry); + int rc = supHardNtLdrCacheOpen(g_aSupNtImpDlls[iDll].pszName, &pLdrEntry, RTErrInfoInitStatic(&ErrInfo)); if (RT_SUCCESS(rc)) { uint8_t *pbBits; rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, (uintptr_t)g_aSupNtImpDlls[iDll].pbImageBase, NULL, NULL, - NULL /*pErrInfo*/); + RTErrInfoInitStatic(&ErrInfo)); if (RT_SUCCESS(rc)) { RTLDRADDR uValue; @@ -820,12 +829,12 @@ SUP_DPRINTF(("supR3HardenedWinGetRealDllSymbol: Error getting %s in %s -> %Rrc\n", pszProcedure, pszDll, rc)); } else - SUP_DPRINTF(("supR3HardenedWinGetRealDllSymbol: supHardNtLdrCacheEntryAllocBits failed on %s: %Rrc\n", - pszDll, rc)); + SUP_DPRINTF(("supR3HardenedWinGetRealDllSymbol: supHardNtLdrCacheEntryAllocBits failed on %s: %Rrc %s\n", + pszDll, rc, ErrInfo.Core.pszMsg)); } else - SUP_DPRINTF(("supR3HardenedWinGetRealDllSymbol: supHardNtLdrCacheOpen failed on %s: %Rrc\n", - pszDll, rc)); + SUP_DPRINTF(("supR3HardenedWinGetRealDllSymbol: supHardNtLdrCacheOpen failed on %s: %Rrc %s\n", + pszDll, rc, ErrInfo.Core.pszMsg)); /* Complications, just call GetProcAddress. */ if (g_enmSupR3HardenedMainState >= SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp 2016-01-19 19:18:37.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp 2016-08-22 14:20:22.000000000 +0000 @@ -360,6 +360,12 @@ #define SUPHARDNT_ADVERSARY_ZONE_ALARM RT_BIT_32(12) /** Digital guardian. */ #define SUPHARDNT_ADVERSARY_DIGITAL_GUARDIAN RT_BIT_32(13) +/** Cylance protect or something (from googling, no available sample copy). */ +#define SUPHARDNT_ADVERSARY_CYLANCE RT_BIT_32(14) +/** BeyondTrust / PowerBroker / something (googling, no available sample copy). */ +#define SUPHARDNT_ADVERSARY_BEYONDTRUST RT_BIT_32(15) +/** Avecto / Defendpoint / Privilege Guard (details from support guy, hoping to get sample copy). */ +#define SUPHARDNT_ADVERSARY_AVECTO RT_BIT_32(16) /** Unknown adversary detected while waiting on child. */ #define SUPHARDNT_ADVERSARY_UNKNOWN RT_BIT_32(31) /** @} */ @@ -1672,6 +1678,37 @@ } /* + * Reject PGHook.dll as it creates a thread from its DllMain that breaks + * our preconditions respawning the 2nd process, resulting in + * VERR_SUP_VP_THREAD_NOT_ALONE. The DLL is being loaded by a user APC + * scheduled during kernel32.dll load notification from a kernel driver, + * so failing the load attempt should not upset anyone. + */ + if (g_enmSupR3HardenedMainState == SUPR3HARDENEDMAINSTATE_WIN_EARLY_STUB_DEVICE_OPENED) + { + static const struct { const char *psz; size_t cch; } s_aUnwantedEarlyDlls[] = + { + { RT_STR_TUPLE("PGHook.dll") }, + }; + + for (unsigned i = 0; i < RT_ELEMENTS(s_aUnwantedEarlyDlls); i++) + { + if (pName->Length < s_aUnwantedEarlyDlls[i].cch * 2) + continue; + PCRTUTF16 pwszTmp = &pName->Buffer[pName->Length / sizeof(RTUTF16) - s_aUnwantedEarlyDlls[i].cch]; + if ( pName->Length != s_aUnwantedEarlyDlls[i].cch * 2 + && pwszTmp[-1] != '\\' + && pwszTmp[-1] != '/') + continue; + if (RTUtf16ICmpAscii(pwszTmp, s_aUnwantedEarlyDlls[i].psz) != 0) + continue; + SUP_DPRINTF(("supR3HardenedMonitor_LdrLoadDll: Refusing to load '%.*ls' as it is expected to create undesirable threads that will upset our respawn checks (returning STATUS_TOO_MANY_THREADS)\n", + pName->Length / sizeof(RTUTF16), pName->Buffer)); + return STATUS_TOO_MANY_THREADS; + } + } + + /* * Absolute path? */ NTSTATUS rcNtResolve = STATUS_SUCCESS; @@ -3543,7 +3580,7 @@ * code bits for it. */ PSUPHNTLDRCACHEENTRY pLdrEntry; - int rc = supHardNtLdrCacheOpen("ntdll.dll", &pLdrEntry); + int rc = supHardNtLdrCacheOpen("ntdll.dll", &pLdrEntry, NULL /*pErrInfo*/); if (RT_FAILURE(rc)) supR3HardenedWinKillChild(pThis, "supR3HardenedWinSetupChildInit", rc, "supHardNtLdrCacheOpen failed on NTDLL: %Rrc\n", rc); @@ -4199,7 +4236,7 @@ if (NT_SUCCESS(rcNt) && NT_SUCCESS(Ios.Status) && Ios.Information > 0) { memcpy(pszErrorInfo, pszPrefix, cchPrefix); - pszErrorInfo[RT_MIN(cbErrorInfo - 1, Ios.Information)] = '\0'; + pszErrorInfo[RT_MIN(cbErrorInfo - 1, cchPrefix + Ios.Information)] = '\0'; SUP_DPRINTF(("supR3HardenedWinReadErrorInfoDevice: '%s'", &pszErrorInfo[cchPrefix])); } else @@ -5066,10 +5103,16 @@ { SUPHARDNT_ADVERSARY_MSE, "NisDrv" }, /*{ SUPHARDNT_ADVERSARY_COMODO, "cmdguard" }, file system */ - { SUPHARDNT_ADVERSARY_COMODO, "inspect" }, - { SUPHARDNT_ADVERSARY_COMODO, "cmdHlp" }, + { SUPHARDNT_ADVERSARY_COMODO, "inspect" }, + { SUPHARDNT_ADVERSARY_COMODO, "cmdHlp" }, + + { SUPHARDNT_ADVERSARY_DIGITAL_GUARDIAN, "dgmaster" }, /* Not verified. */ + + { SUPHARDNT_ADVERSARY_CYLANCE, "cyprotectdrv" }, /* Not verified. */ - { SUPHARDNT_ADVERSARY_DIGITAL_GUARDIAN, "dgmaster" }, /* Not verified. */ + { SUPHARDNT_ADVERSARY_BEYONDTRUST, "privman" }, /* Not verified. */ + + { SUPHARDNT_ADVERSARY_AVECTO, "PGDriver" }, }; static const struct @@ -5184,6 +5227,15 @@ { SUPHARDNT_ADVERSARY_ZONE_ALARM, L"\\SystemRoot\\System32\\AntiTheftCredentialProvider.dll" }, { SUPHARDNT_ADVERSARY_DIGITAL_GUARDIAN, L"\\SystemRoot\\System32\\drivers\\dgmaster.sys" }, + + { SUPHARDNT_ADVERSARY_CYLANCE, L"\\SystemRoot\\System32\\drivers\\cyprotectdrv32.sys" }, + { SUPHARDNT_ADVERSARY_CYLANCE, L"\\SystemRoot\\System32\\drivers\\cyprotectdrv64.sys" }, + + { SUPHARDNT_ADVERSARY_BEYONDTRUST, L"\\SystemRoot\\System32\\drivers\\privman.sys" }, + { SUPHARDNT_ADVERSARY_BEYONDTRUST, L"\\SystemRoot\\System32\\privman64.dll" }, + { SUPHARDNT_ADVERSARY_BEYONDTRUST, L"\\SystemRoot\\System32\\privman32.dll" }, + + { SUPHARDNT_ADVERSARY_AVECTO, L"\\SystemRoot\\System32\\drivers\\PGDriver.sys" }, }; uint32_t fFound = 0; @@ -5334,7 +5386,7 @@ * Init g_uNtVerCombined. (The code is shared with SUPR3.lib and lives in * SUPHardenedVerfiyImage-win.cpp.) */ - supR3HardenedWinInitVersion(); + supR3HardenedWinInitVersion(false /*fEarly*/); g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_WIN_VERSION_INITIALIZED; /* @@ -5552,7 +5604,7 @@ /* * Init g_uNtVerCombined as well as we can at this point. */ - supR3HardenedWinInitVersion(); + supR3HardenedWinInitVersion(true /*fEarly*/); /* * Convert the arguments to UTF-8 so we can open the log file if specified. @@ -5567,12 +5619,13 @@ int cArgs; char **papszArgs = suplibCommandLineToArgvWStub(CmdLineStr.Buffer, CmdLineStr.Length / sizeof(WCHAR), &cArgs); supR3HardenedOpenLog(&cArgs, papszArgs); - SUP_DPRINTF(("supR3HardenedVmProcessInit: uNtDllAddr=%p\n", uNtDllAddr)); + SUP_DPRINTF(("supR3HardenedVmProcessInit: uNtDllAddr=%p g_uNtVerCombined=%#x\n", uNtDllAddr, g_uNtVerCombined)); /* * Set up the direct system calls so we can more easily hook NtCreateSection. */ - supR3HardenedWinInitSyscalls(true /*fReportErrors*/); + RTERRINFOSTATIC ErrInfo; + supR3HardenedWinInitSyscalls(true /*fReportErrors*/, RTErrInfoInitStatic(&ErrInfo)); /* * Determine the executable path and name. Will NOT determine the windows style @@ -5604,15 +5657,16 @@ { SUP_DPRINTF(("supR3HardenedVmProcessInit: Opening vboxdrv stub...\n")); supR3HardenedWinOpenStubDevice(); + g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_WIN_EARLY_STUB_DEVICE_OPENED; } else if (cArgs >= 1 && suplibHardenedStrCmp(papszArgs[0], SUPR3_RESPAWN_2_ARG0) == 0) { SUP_DPRINTF(("supR3HardenedVmProcessInit: Opening vboxdrv...\n")); supR3HardenedMainOpenDevice(); + g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_WIN_EARLY_REAL_DEVICE_OPENED; } else supR3HardenedFatal("Unexpected first argument '%s'!\n", papszArgs[0]); - g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_WIN_EARLY_DEVICE_OPENED; /* * Reinstall the NtDll patches since there is a slight possibility that @@ -5626,14 +5680,16 @@ */ SUP_DPRINTF(("supR3HardenedVmProcessInit: Restoring LdrInitializeThunk...\n")); PSUPHNTLDRCACHEENTRY pLdrEntry; - int rc = supHardNtLdrCacheOpen("ntdll.dll", &pLdrEntry); + int rc = supHardNtLdrCacheOpen("ntdll.dll", &pLdrEntry, RTErrInfoInitStatic(&ErrInfo)); if (RT_FAILURE(rc)) - supR3HardenedFatal("supR3HardenedVmProcessInit: supHardNtLdrCacheOpen failed on NTDLL: %Rrc\n", rc); + supR3HardenedFatal("supR3HardenedVmProcessInit: supHardNtLdrCacheOpen failed on NTDLL: %Rrc %s\n", + rc, ErrInfo.Core.pszMsg); uint8_t *pbBits; - rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, uNtDllAddr, NULL, NULL, NULL /*pErrInfo*/); + rc = supHardNtLdrCacheEntryGetBits(pLdrEntry, &pbBits, uNtDllAddr, NULL, NULL, RTErrInfoInitStatic(&ErrInfo)); if (RT_FAILURE(rc)) - supR3HardenedFatal("supR3HardenedVmProcessInit: supHardNtLdrCacheEntryGetBits failed on NTDLL: %Rrc\n", rc); + supR3HardenedFatal("supR3HardenedVmProcessInit: supHardNtLdrCacheEntryGetBits failed on NTDLL: %Rrc %s\n", + rc, ErrInfo.Core.pszMsg); RTLDRADDR uValue; rc = RTLdrGetSymbolEx(pLdrEntry->hLdrMod, pbBits, uNtDllAddr, UINT32_MAX, "LdrInitializeThunk", &uValue); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile 2016-01-19 19:18:38.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/Makefile 2016-08-22 14:20:22.000000000 +0000 @@ -202,13 +202,13 @@ install: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ + install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; \ rm -f /etc/vbox/module_not_compiled install_rpm: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) + install -m 0644 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) else # eq ($(MAKECMDGOALS),clean) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c 2016-01-19 19:18:38.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c 2016-08-22 14:20:22.000000000 +0000 @@ -134,8 +134,10 @@ /* Update the stats. */ pPriv->Stats.tx_packets++; pPriv->Stats.tx_bytes += pSkb->len; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) /* Update transmission time stamp. */ pNetDev->trans_start = jiffies; +#endif /* Nothing else to do, just free the sk_buff. */ dev_kfree_skb(pSkb); return 0; diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/Makefile virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/Makefile --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/Makefile 2016-01-19 19:18:38.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/Makefile 2016-08-22 14:20:22.000000000 +0000 @@ -206,13 +206,13 @@ install: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ + install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; \ rm -f /etc/vbox/module_not_compiled install_rpm: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) + install -m 0644 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) else # eq ($(MAKECMDGOALS),clean) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c 2016-01-19 19:18:38.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c 2016-08-22 14:20:22.000000000 +0000 @@ -34,6 +34,9 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) +#include +#endif #include #include #include @@ -125,7 +128,8 @@ # define VBOX_HAVE_SKB_VLAN #else # ifdef RHEL_RELEASE_CODE -# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2) +# if (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 2) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0)) || \ + (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 8) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7, 0)) # define VBOX_HAVE_SKB_VLAN # endif # endif diff -Nru virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxPci/linux/Makefile virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxPci/linux/Makefile --- virtualbox-4.3.36-dfsg/src/VBox/HostDrivers/VBoxPci/linux/Makefile 2016-01-19 19:18:38.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/HostDrivers/VBoxPci/linux/Makefile 2016-08-22 14:20:23.000000000 +0000 @@ -205,12 +205,12 @@ install: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ + install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; install_rpm: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) + install -m 0644 $(MODULE).$(MODULE_EXT) $(MODULE_DIR) else # eq ($(MAKECMDGOALS),clean) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Installer/common/vboxapisetup.py virtualbox-4.3.40-dfsg/src/VBox/Installer/common/vboxapisetup.py --- virtualbox-4.3.36-dfsg/src/VBox/Installer/common/vboxapisetup.py 2016-01-19 19:18:42.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Installer/common/vboxapisetup.py 2016-08-22 14:20:26.000000000 +0000 @@ -45,9 +45,11 @@ # See http://docs.python.org/distutils/index.html def main(argv): - vboxDest=os.environ.get("VBOX_INSTALL_PATH", None) + vboxDest=os.environ.get("VBOX_MSI_INSTALL_PATH", None) if vboxDest is None: - raise Exception("No VBOX_INSTALL_PATH defined, exiting") + vboxDest = os.environ.get('VBOX_INSTALL_PATH', None) + if vboxDest is None: + raise Exception("No VBOX_INSTALL_PATH defined, exiting") vboxVersion=os.environ.get("VBOX_VERSION", None) if vboxVersion is None: # Should we use VBox version for binding module versioning? diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Installer/linux/Makefile.include.footer virtualbox-4.3.40-dfsg/src/VBox/Installer/linux/Makefile.include.footer --- virtualbox-4.3.36-dfsg/src/VBox/Installer/linux/Makefile.include.footer 2016-01-19 19:18:42.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Installer/linux/Makefile.include.footer 2016-08-22 14:20:26.000000000 +0000 @@ -82,7 +82,7 @@ install: $(MODULE) @mkdir -p $(MODULE_DIR); \ - install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ + install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \ PATH="$(PATH):/bin:/sbin" depmod -a; endif # eq($(MAKECMDGOALS),clean) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Installer/win/Makefile.kmk virtualbox-4.3.40-dfsg/src/VBox/Installer/win/Makefile.kmk --- virtualbox-4.3.36-dfsg/src/VBox/Installer/win/Makefile.kmk 2016-01-19 19:18:43.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Installer/win/Makefile.kmk 2016-08-22 14:20:27.000000000 +0000 @@ -365,7 +365,7 @@ $(VBOX_PATH_WIX)/difxapp_x86.wixlib, \ $(VBOX_PATH_WIX)/difxapp_x64.wixlib) $(RM) -f $(VBOX_WIN_INST_OUT_DIR)/NLS/$(lang).mst - $(call VBOX_SIGN_FILE_FN,$$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV) ($(KBUILD_TARGET_ARCH))) + $(call VBOX_SIGN_FILE_FN,$$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV) ($(KBUILD_TARGET_ARCH)),,,disable-dual-signing) endef $(foreach lang,$(VBOX_INSTALLER_LANGUAGES), \ @@ -402,7 +402,7 @@ $(VBOX_PATH_WIX)/difxapp_x86.wixlib, \ $(VBOX_PATH_WIX)/difxapp_x64.wixlib) $(RM) -f $(VBOX_WIN_INST_OUT_DIR)/NLS/$(lang).mst - $(call VBOX_SIGN_FILE_FN,$$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV) ($(KBUILD_TARGET_ARCH))) + $(call VBOX_SIGN_FILE_FN,$$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV) ($(KBUILD_TARGET_ARCH)),,,disable-dual-signing) endef $(if $(VBOX_WITH_MSM_INSTALL), \ @@ -771,7 +771,7 @@ $(REDIRECT) -C $(@D) -- \ wscript.exe $(VBOX_PATH_WISUMINFO) $(VBOX_WIN_INST_OUT_DIR)/$(PACKAGE_NAME_LANG)_en_US.msi $(VBOX_INS_PROD_LANG) $(CP) -f $(VBOX_WIN_INST_OUT_DIR)/$(PACKAGE_NAME_LANG)_en_US.msi $@ - $(call VBOX_SIGN_FILE_FN,$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV)) + $(call VBOX_SIGN_FILE_FN,$@,$(VBOX_PRODUCT) $(VBOX_VERSION_STRING)r$(VBOX_SVN_REV),,,disable-dual-signing) if defined(VBOX_WITH_COMBINED_PACKAGE) && "$(KBUILD_TARGET_ARCH)" == "x86" diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/glue/glue-java.xsl virtualbox-4.3.40-dfsg/src/VBox/Main/glue/glue-java.xsl --- virtualbox-4.3.36-dfsg/src/VBox/Main/glue/glue-java.xsl 2016-01-19 19:18:44.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/glue/glue-java.xsl 2016-08-22 14:20:28.000000000 +0000 @@ -10,7 +10,7 @@ XSLT stylesheet that generates Java glue code for XPCOM, MSCOM and JAX-WS from VirtualBox.xidl. - Copyright (C) 2010-2014 Oracle Corporation + Copyright (C) 2010-2016 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -43,10 +43,17 @@ + + + + + /* - * Copyright (C) 2010-2014 Oracle Corporation + * Copyright (C) 2010-2016 Oracle Corporation * * This file is part of the VirtualBox SDK, as available from * http://www.virtualbox.org. This library is free software; you can @@ -621,11 +628,17 @@ + + + + this.getObjMgr().preventObjRelease(); + try { + @@ -648,12 +661,18 @@ } catch (InvalidObjectFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.getObjMgr(), this.port); } catch (RuntimeFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.getObjMgr(), this.port); } + + finally + { + getObjMgr().allowObjRelease(); + } + @@ -1118,13 +1137,13 @@ - + - + @@ -1168,11 +1187,11 @@ - + - + @@ -1809,14 +1828,78 @@ - private VboxPortType port; + private VboxPortType port; + private ObjectRefManager objMgr; + + + + + + + + + + + + + + + + + + - + { this.real = real; this.port = port; + this.objMgr = objMgr; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + @@ -1870,18 +1953,26 @@ + { - - - - - - - - - + + + + + + + + + + + + + + + + } @@ -1954,7 +2045,9 @@ ) { - + + + @@ -2048,9 +2141,11 @@ - + - + + + } @@ -2135,7 +2230,7 @@ - + @@ -2332,9 +2427,9 @@ - + { - super(wrapped, port); + super(wrapped, objMgr, port); } @@ -2401,7 +2496,10 @@ { - + + + + @@ -2412,7 +2510,10 @@ - + + + + } @@ -3875,12 +3976,15 @@ public class IUnknown { protected String obj; + protected ObjectRefManager objMgr; protected final VboxPortType port; - public IUnknown(String obj, VboxPortType port) + public IUnknown(String obj, ObjectRefManager objMgr, VboxPortType port) { - this.obj = obj; - this.port = port; + this.obj = obj; + this.objMgr = objMgr; + this.port = port; + objMgr.registerObj(this); } public final String getWrapped() @@ -3893,6 +3997,11 @@ return this.port; } + public final ObjectRefManager getObjMgr() + { + return this.objMgr; + } + public synchronized void releaseRemote() throws WebServiceException { if (obj == null) @@ -3938,18 +4047,18 @@ public class Helper { - public static List wrap(Class wrapperClass, VboxPortType pt, List values) + public static List wrap(Class wrapperClass, ObjectRefManager objMgr, VboxPortType pt, List values) { try { if (values == null) return null; - Constructor c = wrapperClass.getConstructor(String.class, VboxPortType.class); + Constructor c = wrapperClass.getConstructor(String.class, ObjectRefManager.class, VboxPortType.class); List ret = new ArrayList(values.size()); for (String v : values) { - ret.add(c.newInstance(v, pt)); + ret.add(c.newInstance(v, objMgr, pt)); } return ret; } @@ -3971,18 +4080,18 @@ } } - public static List wrap2(Class wrapperClass1, Class wrapperClass2, VboxPortType pt, List values) + public static List wrap2(Class wrapperClass1, Class wrapperClass2, ObjectRefManager objMgr, VboxPortType pt, List values) { try { if (values == null) return null; - Constructor c = wrapperClass1.getConstructor(wrapperClass2, VboxPortType.class); + Constructor c = wrapperClass1.getConstructor(wrapperClass2, ObjectRefManager.class, VboxPortType.class); List ret = new ArrayList(values.size()); for (T2 v : values) { - ret.add(c.newInstance(v, pt)); + ret.add(c.newInstance(v, objMgr, pt)); } return ret; } @@ -4207,7 +4316,7 @@ errorInfo = null; } - public VBoxException(String message, Throwable cause, VboxPortType port) + public VBoxException(String message, Throwable cause, ObjectRefManager objMgr, VboxPortType port) { super(message, cause); if (cause instanceof RuntimeFaultMsg) @@ -4216,7 +4325,7 @@ RuntimeFault f = m.getFaultInfo(); resultCode = f.getResultCode(); String retVal = f.getReturnval(); - errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, port) : null; + errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, objMgr, port) : null; } else resultCode = -1; @@ -4247,10 +4356,19 @@ import java.net.URL; import java.math.BigInteger; +import java.util.Iterator; import java.util.List; +import java.util.LinkedList; import java.util.Map; import java.util.HashMap; import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.lang.Integer; +import java.lang.ref.WeakReference; +import java.lang.ref.ReferenceQueue; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Holder; @@ -4378,6 +4496,271 @@ } +/** + * This class manages the object references between us and the webservice server. + * It makes sure that the object on the server side is destroyed when all + */ +class ObjectRefManager +{ + private final static ReferenceQueue refQ = new ReferenceQueue(); + + private final ConcurrentMap map = new ConcurrentHashMap(); + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private final ObjRefMgrCleanupThread objRefMgrCleanup; + + public ObjectRefManager() + { + this.objRefMgrCleanup = new ObjRefMgrCleanupThread(this, 100); + this.objRefMgrCleanup.start(); + } + + /** + * Prevents the object reference manager cleanup thread from releasing any + * server side objects to avoid a fundamental race in the multi threaded + * java environment where it is possible that a wrapper got the object ID + * from the server but couldn't create the local stub protecting the object + * before the cleanup thread released it. + */ + public void preventObjRelease() + { + lock.readLock().lock(); + } + + /** + * Allows releasing server side objects from the cleanup thread again. + */ + public void allowObjRelease() + { + lock.readLock().unlock(); + } + + /** + * Marks the start of a run to release server side objects which don't hold + * a reference locally anymore. + */ + public void startObjRelease() + { + lock.writeLock().lock(); + } + + /** + * Marks the end of a cleanup run. + */ + public void endObjRelease() + { + lock.writeLock().unlock(); + } + + /** + * Registers a new stub object for automatic reference managing. + */ + public void registerObj(IUnknown obj) + { + assert lock.getReadLockCount() > 0; + ManagedObjRef ref = new ManagedObjRef(obj); + + ManagedObj mgrobj = map.get(obj.getWrapped()); + if (mgrobj != null) + { + mgrobj.addObject(ref); + } + else + { + /* Create new. */ + mgrobj = new ManagedObj(obj.getWrapped(), obj.getRemoteWSPort()); + mgrobj.addObject(ref); + map.put(obj.getWrapped(), mgrobj); + } + } + + /** + * Removes a garbage collected object reference from our reference manager. + * + * Returns the server side object wrapper if there is no stub referencing it + * anymore otherwise null is returned. + */ + public ManagedObj unregisterObj(ManagedObjRef objRef) + { + ManagedObj obj = this.map.get(objRef.objId); + + assert obj != null; + obj.removeObject(objRef); + if (!obj.isReferenced()) + return obj; + + return null; + } + + public void releaseRemoteObj(ManagedObj obj) + { + assert lock.isWriteLockedByCurrentThread(); + + if (!obj.isReferenced()) + { + try + { + obj.port.iManagedObjectRefRelease(obj.objId); + } + catch (InvalidObjectFaultMsg e) + { + throw new WebServiceException(e); + } + catch (RuntimeFaultMsg e) + { + throw new WebServiceException(e); + } + finally + { + this.map.remove(obj.objId); + } + } + } + + /** + * An object which is living on the server side. This can be referenced + * by multiple stub objects here. + */ + static class ManagedObj + { + private final String objId; + private final VboxPortType port; + private final ConcurrentLinkedQueue refQ; + + ManagedObj(String objId, VboxPortType port) + { + this.objId = objId; + this.port = port; + this.refQ = new ConcurrentLinkedQueue(); + } + + public void addObject(ManagedObjRef obj) + { + this.refQ.add(obj); + } + + public void removeObject(ManagedObjRef obj) + { + this.refQ.remove(obj); + } + + public boolean isReferenced() + { + return !this.refQ.isEmpty(); + } + } + + /** + * A private class extending WeakReference to get notified about garbage + * collected stub objects. + */ + static class ManagedObjRef extends WeakReference + { + final String objId; + + ManagedObjRef(IUnknown obj) + { + super(obj, refQ); + this.objId = obj.getWrapped(); + } + } + + /** + * A private class implementing a thread getting notified + * about garbage collected objects so it can release the object on the + * server side if it is not used anymore. + */ + static class ObjRefMgrCleanupThread extends Thread + { + ObjectRefManager objRefMgr; + int cStubsReleased; + int cStubsReleaseThreshold; + HashMap mapToRelease = new HashMap(); + + ObjRefMgrCleanupThread(ObjectRefManager objRefMgr) + { + init(objRefMgr, 500); + } + + ObjRefMgrCleanupThread(ObjectRefManager objRefMgr, int cStubsReleaseThreshold) + { + init(objRefMgr, cStubsReleaseThreshold); + } + + private void init(ObjectRefManager objRefMgr, int cStubsReleaseThreshold) + { + this.objRefMgr = objRefMgr; + this.cStubsReleased = 0; + this.cStubsReleaseThreshold = cStubsReleaseThreshold; + setName("ObjectRefManager-VBoxWSObjRefGcThrd"); + /* + * setDaemon() makes sure the jvm exits and is not blocked + * if the thread is still running so we don't have to care about + * tearing it down. + */ + setDaemon(true); + } + + public void run() + { + while (true) + { + while (cStubsReleased < cStubsReleaseThreshold) + { + try + { + /* Accumulate a few objects before we start. */ + while (cStubsReleased < cStubsReleaseThreshold) + { + ManagedObjRef ref = (ManagedObjRef)refQ.remove(); + ManagedObj obj = this.objRefMgr.unregisterObj(ref); + /* + * If the server side object is not referenced anymore + * promote to map for releasing later. + */ + if (obj != null && !mapToRelease.containsKey(ref.objId)) + mapToRelease.put(ref.objId, obj); + + cStubsReleased++; + } + } + catch (InterruptedException e) + { /* ignore */ } + catch (javax.xml.ws.WebServiceException e) + { /* ignore */ } + } + + /* + * After we released enough stubs we go over all non referenced + * server side objects and release them if they were not + * referenced again in between. + */ + cStubsReleased = 0; + if (!mapToRelease.isEmpty()) + { + this.objRefMgr.startObjRelease(); + try + { + Iterator it = mapToRelease.values().iterator(); + while (it.hasNext()) + { + ManagedObj obj = it.next(); + this.objRefMgr.releaseRemoteObj(obj); + } + + mapToRelease.clear(); + } + catch (javax.xml.ws.WebServiceException e) + { /* ignore */ } + finally + { + this.objRefMgr.endObjRelease(); + } + } + } + } + } +} + class VBoxTLSSocketFactory extends SSLSocketFactory { private final SSLSocketFactory sf; @@ -4474,6 +4857,7 @@ public class VirtualBoxManager { private static PortPool pool = new PortPool(true); + private static final ObjectRefManager objMgr = new ObjectRefManager(); protected VboxPortType port; private IVirtualBox vbox; @@ -4513,7 +4897,15 @@ put("com.sun.xml.ws.transport.https.client.SSLSocketFactory", sf); String handle = port.iWebsessionManagerLogon(username, passwd); - this.vbox = new IVirtualBox(handle, port); + this.objMgr.preventObjRelease(); + try + { + this.vbox = new IVirtualBox(handle, this.objMgr, port); + } + finally + { + this.objMgr.allowObjRelease(); + } } catch (Throwable t) { @@ -4523,7 +4915,7 @@ this.port = null; } // we have to throw smth derived from RuntimeException - throw new VBoxException(t.getMessage(), t, this.port); + throw new VBoxException(t.getMessage(), t, this.objMgr, this.port); } } @@ -4531,7 +4923,6 @@ Map requestContext, Map responseContext) { this.port = pool.getPort(); - try { ((BindingProvider)port).getRequestContext(); @@ -4544,7 +4935,15 @@ ((BindingProvider)port).getRequestContext(). put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); String handle = port.iWebsessionManagerLogon(username, passwd); - this.vbox = new IVirtualBox(handle, port); + this.objMgr.preventObjRelease(); + try + { + this.vbox = new IVirtualBox(handle, this.objMgr, port); + } + finally + { + this.objMgr.allowObjRelease(); + } } catch (Throwable t) { @@ -4554,7 +4953,7 @@ this.port = null; } // we have to throw smth derived from RuntimeException - throw new VBoxException(t.getMessage(), t, this.port); + throw new VBoxException(t.getMessage(), t, this.objMgr, this.port); } } @@ -4570,11 +4969,11 @@ } catch (InvalidObjectFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.objMgr, this.port); } catch (RuntimeFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.objMgr, this.port); } finally { @@ -4605,15 +5004,23 @@ try { String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped()); - return new ISession(handle, port); + this.objMgr.preventObjRelease(); + try + { + return new ISession(handle, this.objMgr, port); + } + finally + { + this.objMgr.allowObjRelease(); + } } catch (InvalidObjectFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.objMgr, this.port); } catch (RuntimeFaultMsg e) { - throw new VBoxException(e.getMessage(), e, this.port); + throw new VBoxException(e.getMessage(), e, this.objMgr, this.port); } } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/src-client/ConsoleImpl.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/src-client/ConsoleImpl.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/src-client/ConsoleImpl.cpp 2016-01-19 19:18:45.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/src-client/ConsoleImpl.cpp 2016-08-22 14:20:29.000000000 +0000 @@ -9456,7 +9456,7 @@ /* Set up a build identifier so that it can be seen from core dumps what * exact build was used to produce the core. */ - static char saBuildID[40]; + static char saBuildID[48]; RTStrPrintf(saBuildID, sizeof(saBuildID), "%s%s%s%s VirtualBox %s r%u %s%s%s%s", "BU", "IL", "DI", "D", RTBldCfgVersion(), RTBldCfgRevision(), "BU", "IL", "DI", "D"); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/Performance.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/Performance.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/Performance.cpp 2016-01-19 19:18:46.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/Performance.cpp 2016-08-22 14:20:30.000000000 +0000 @@ -741,7 +741,14 @@ HRESULT hrc = host->FindHostNetworkInterfaceByName(com::Bstr(mInterfaceName).raw(), networkInterface.asOutParam()); if (SUCCEEDED(hrc)) { - LogRel(("Failed to collect network metrics for %s: %Rrc (%d).\n", mInterfaceName.c_str(), mRc, mRc)); + static uint32_t s_tsLogRelLast; + uint32_t tsNow = RTTimeProgramSecTS(); + if ( tsNow < RT_SEC_1HOUR + || (tsNow - s_tsLogRelLast >= 60)) + { + s_tsLogRelLast = tsNow; + LogRel(("Failed to collect network metrics for %s: %Rrc (%d). Max one msg/min.\n", mInterfaceName.c_str(), mRc, mRc)); + } mRc = VINF_SUCCESS; } } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp 2016-01-19 19:18:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp 2016-08-22 14:20:31.000000000 +0000 @@ -397,7 +397,14 @@ ksAdapter = kstat_lookup(mKC, szModule, uInstance, (char *)name); if (ksAdapter == 0) { - LogRel(("Failed to get network statistics for %s\n", name)); + static uint32_t s_tsLogRelLast; + uint32_t tsNow = RTTimeProgramSecTS(); + if ( tsNow < RT_SEC_1HOUR + || (tsNow - s_tsLogRelLast >= 60)) + { + s_tsLogRelLast = tsNow; + LogRel(("Failed to get network statistics for %s. Max one msg/min.\n", name)); + } return VERR_INTERNAL_ERROR; } } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/win/svcmain.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/win/svcmain.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/win/svcmain.cpp 2016-01-19 19:18:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/win/svcmain.cpp 2016-08-22 14:20:31.000000000 +0000 @@ -354,6 +354,12 @@ return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, vrc); } + /* Set up a build identifier so that it can be seen from core dumps what + * exact build was used to produce the core. Same as in Console::i_powerUpThread(). */ + static char saBuildID[48]; + RTStrPrintf(saBuildID, sizeof(saBuildID), "%s%s%s%s VirtualBox %s r%u %s%s%s%s", + "BU", "IL", "DI", "D", RTBldCfgVersion(), RTBldCfgRevision(), "BU", "IL", "DI", "D"); + int nRet = 0; HRESULT hRes = com::Initialize(); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/xpcom/server.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/xpcom/server.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/src-server/xpcom/server.cpp 2016-01-19 19:18:47.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/src-server/xpcom/server.cpp 2016-08-22 14:20:31.000000000 +0000 @@ -905,6 +905,12 @@ if (RT_FAILURE(vrc)) return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, vrc); + /* Set up a build identifier so that it can be seen from core dumps what + * exact build was used to produce the core. Same as in Console::i_powerUpThread(). */ + static char saBuildID[48]; + RTStrPrintf(saBuildID, sizeof(saBuildID), "%s%s%s%s VirtualBox %s r%u %s%s%s%s", + "BU", "IL", "DI", "D", RTBldCfgVersion(), RTBldCfgRevision(), "BU", "IL", "DI", "D"); + daemon_pipe_wr = PR_GetInheritedFD(VBOXSVC_STARTUP_PIPE_NAME); RTEnvUnset("NSPR_INHERIT_FDS"); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/webservice/vboxweb.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/webservice/vboxweb.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/webservice/vboxweb.cpp 2016-01-19 19:18:48.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/webservice/vboxweb.cpp 2016-08-22 14:20:32.000000000 +0000 @@ -1278,13 +1278,14 @@ WEBDEBUG(("Watchdog thread started\n")); + uint32_t tNextStat = 0; + while (1) { WEBDEBUG(("Watchdog: sleeping %d seconds\n", g_iWatchdogCheckInterval)); RTThreadSleep(g_iWatchdogCheckInterval * 1000); - time_t tNow; - time(&tNow); + uint32_t tNow = RTTimeProgramSecTS(); // we're messing with sessions, so lock them util::AutoWriteLock lock(g_pSessionsLockHandle COMMA_LOCKVAL_SRC_POS); @@ -1316,6 +1317,28 @@ if (pSystemProperties) pSystemProperties->COMSETTER(WebServiceAuthLibrary)(com::Bstr(g_pcszAuthentication).raw()); } + + // Log some MOR usage statistics every 5 minutes, but only if there's + // something worth logging (at least one reference or a transition to + // zero references). Avoids useless log spamming in idle webservice. + if (tNow >= tNextStat) + { + size_t cMOR = 0; + it = g_mapSessions.begin(); + itEnd = g_mapSessions.end(); + while (it != itEnd) + { + cMOR += it->second->CountRefs(); + ++it; + } + static bool fLastZero = false; + if (cMOR || !fLastZero) + LogRel(("Statistics: %zu websessions, %zu references\n", + g_mapSessions.size(), cMOR)); + fLastZero = (cMOR == 0); + while (tNextStat <= tNow) + tNextStat += 5 * 60; /* 5 minutes */ + } } WEBDEBUG(("Watchdog thread ending\n")); @@ -1880,7 +1903,15 @@ */ void WebServiceSession::touch() { - time(&_tLastObjectLookup); + _tLastObjectLookup = RTTimeProgramSecTS(); +} + +/** + * Counts the number of managed object references in this websession. + */ +size_t WebServiceSession::CountRefs() +{ + return _pp->_mapManagedObjectsById.size(); } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/webservice/vboxweb.h virtualbox-4.3.40-dfsg/src/VBox/Main/webservice/vboxweb.h --- virtualbox-4.3.36-dfsg/src/VBox/Main/webservice/vboxweb.h 2016-01-19 19:18:48.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/webservice/vboxweb.h 2016-08-22 14:20:32.000000000 +0000 @@ -2,7 +2,7 @@ * vboxweb.h: * header file for "real" web server code. * - * Copyright (C) 2006-2013 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -111,7 +111,7 @@ ManagedObjectRef *_pISession; - time_t _tLastObjectLookup; + uint32_t _tLastObjectLookup; // hide the copy constructor because we're not copyable WebServiceSession(const WebServiceSession ©From); @@ -136,14 +136,14 @@ void touch(); - time_t getLastObjectLookup() const + uint32_t getLastObjectLookup() const { return _tLastObjectLookup; } static WebServiceSession* findSessionFromRef(const WSDLT_ID &id); - void DumpRefs(); + size_t CountRefs(); }; /** diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Main/xml/Settings.cpp virtualbox-4.3.40-dfsg/src/VBox/Main/xml/Settings.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Main/xml/Settings.cpp 2016-01-19 19:18:48.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Main/xml/Settings.cpp 2016-08-22 14:20:32.000000000 +0000 @@ -2262,6 +2262,13 @@ { NetworkAdapter nic; + if (m->sv == SettingsVersion_Future) + { + /* Future defaults: cable connected and PCnet-FAST III. */ + nic.fCableConnected = true; + nic.type = NetworkAdapterType_Am79C973; + } + if (!pelmAdapter->getAttributeValue("slot", nic.ulSlot)) throw ConfigFileError(this, pelmAdapter, N_("Required Adapter/@slot attribute is missing")); @@ -2645,6 +2652,13 @@ Hardware &hw, Storage &strg) { + if (m->sv == SettingsVersion_Future) + { + /* Future defaults: VRDE disabled and audio adapter disabled. */ + hw.vrdeSettings.fEnabled = false; + hw.audioAdapter.fEnabled = false; + } + if (!elmHardware.getAttributeValue("version", hw.strVersion)) { /* KLUDGE ALERT! For a while during the 3.1 development this was not diff -Nru virtualbox-4.3.36-dfsg/src/VBox/NetworkServices/NAT/pxtcp.c virtualbox-4.3.40-dfsg/src/VBox/NetworkServices/NAT/pxtcp.c --- virtualbox-4.3.36-dfsg/src/VBox/NetworkServices/NAT/pxtcp.c 2016-01-19 19:18:49.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/NetworkServices/NAT/pxtcp.c 2016-08-22 14:20:32.000000000 +0000 @@ -1689,11 +1689,11 @@ status = getsockopt(pxtcp->sock, SOL_SOCKET, SO_ERROR, (char *)&sockerr, &optlen); if (status == SOCKET_ERROR) { /* should not happen */ - DPRINTF(("sock %d: SO_ERROR failed: %R[sockerr]\n", + DPRINTF(("sock %d: POLLERR: SO_ERROR failed: %R[sockerr]\n", fd, SOCKERRNO())); } else { - DPRINTF0(("sock %d: %R[sockerr]\n", fd, sockerr)); + DPRINTF0(("sock %d: POLLERR: %R[sockerr]\n", fd, sockerr)); } return pxtcp_schedule_reset(pxtcp); } @@ -1710,7 +1710,7 @@ nread = pxtcp_sock_read(pxtcp, &stop_pollin); if (nread < 0) { sockerr = -(int)nread; - DPRINTF0(("sock %d: %R[sockerr]\n", fd, sockerr)); + DPRINTF0(("sock %d: POLLIN: %R[sockerr]\n", fd, sockerr)); return pxtcp_schedule_reset(pxtcp); } @@ -1738,8 +1738,41 @@ #else if (revents & POLLHUP) { DPRINTF(("sock %d: HUP\n", fd)); + #if HAVE_TCP_POLLHUP == POLLIN /* + * XXX: OSX reports POLLHUP once more when inbound is already + * half-closed (which has already been reported as a "normal" + * POLLHUP, handled below), the socket is polled for POLLOUT + * (guest sends a lot of data that we can't push out fast + * enough), and remote sends a reset - e.g. an http client + * that half-closes after request and then aborts the transfer. + * + * It really should have been reported as POLLERR, but it + * seems OSX never reports POLLERR for sockets. + */ +#if defined(RT_OS_DARWIN) + { + socklen_t optlen = (socklen_t)sizeof(sockerr); + + status = getsockopt(pxtcp->sock, SOL_SOCKET, SO_ERROR, + (char *)&sockerr, &optlen); + if (status == SOCKET_ERROR) { /* should not happen */ + DPRINTF(("sock %d: POLLHUP: SO_ERROR failed: %R[sockerr]\n", + fd, SOCKERRNO())); + sockerr = ECONNRESET; + } + else if (sockerr != 0) { + DPRINTF0(("sock %d: POLLHUP: %R[sockerr]\n", fd, sockerr)); + } + + if (sockerr != 0) { /* XXX: should have been POLLERR */ + return pxtcp_schedule_reset(pxtcp); + } + } +#endif /* RT_OS_DARWIN */ + + /* * Remote closed inbound. */ if (!pxtcp->outbound_close_done) { diff -Nru virtualbox-4.3.36-dfsg/src/VBox/NetworkServices/NAT/rtmon_linux.c virtualbox-4.3.40-dfsg/src/VBox/NetworkServices/NAT/rtmon_linux.c --- virtualbox-4.3.36-dfsg/src/VBox/NetworkServices/NAT/rtmon_linux.c 2016-01-19 19:18:49.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/NetworkServices/NAT/rtmon_linux.c 2016-08-22 14:20:32.000000000 +0000 @@ -170,7 +170,7 @@ size_t gwlen; int oif; - DPRINTF2(("nlmsg type %d flags 0x%x\n", + DPRINTF2(("nlmsg seq %d type %d flags 0x%x\n", nh->nlmsg_seq, nh->nlmsg_type, nh->nlmsg_flags)); if (nh->nlmsg_type == NLMSG_DONE) { diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/crypto/pkcs7-sanity.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/crypto/pkcs7-sanity.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/crypto/pkcs7-sanity.cpp 2016-01-19 19:18:53.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/crypto/pkcs7-sanity.cpp 2016-08-22 14:20:36.000000000 +0000 @@ -183,8 +183,6 @@ "Expected exactly one value for message-digest attrib, found: %u", pAttrib->uValues.pOctetStrings->cItems); } - else - AssertReturn(pAttrib->enmType == RTCRPKCS7ATTRIBUTETYPE_UNKNOWN, VERR_INTERNAL_ERROR_3); } if (!fFoundContentInfo) diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/ldr/ldrPE.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/ldr/ldrPE.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/ldr/ldrPE.cpp 2016-01-19 19:18:54.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/ldr/ldrPE.cpp 2016-08-22 14:20:37.000000000 +0000 @@ -2930,32 +2930,36 @@ /* * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff. */ - IMAGE_LOAD_CONFIG_DIRECTORY32_V4 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V4 volatile *)pLoadCfg; - IMAGE_LOAD_CONFIG_DIRECTORY64_V4 volatile *pLoadCfg64 = pLoadCfg; + IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *)pLoadCfg; + IMAGE_LOAD_CONFIG_DIRECTORY64_V5 volatile *pLoadCfg64 = pLoadCfg; - pLoadCfg64->CodeIntegrity.Reserved = pLoadCfg32->CodeIntegrity.Reserved; - pLoadCfg64->CodeIntegrity.CatalogOffset = pLoadCfg32->CodeIntegrity.CatalogOffset; - pLoadCfg64->CodeIntegrity.Catalog = pLoadCfg32->CodeIntegrity.Catalog; - pLoadCfg64->CodeIntegrity.Flags = pLoadCfg32->CodeIntegrity.Flags; - pLoadCfg64->GuardFlags = pLoadCfg32->GuardFlags; - pLoadCfg64->GuardCFFunctionCount = pLoadCfg32->GuardCFFunctionCount; - pLoadCfg64->GuardCFFunctionTable = pLoadCfg32->GuardCFFunctionTable; - pLoadCfg64->Reserved2 = pLoadCfg32->Reserved2; - pLoadCfg64->GuardCFCCheckFunctionPointer= pLoadCfg32->GuardCFCCheckFunctionPointer; - pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; - pLoadCfg64->SEHandlerTable = pLoadCfg32->SEHandlerTable; - pLoadCfg64->SecurityCookie = pLoadCfg32->SecurityCookie; - pLoadCfg64->EditList = pLoadCfg32->EditList; - pLoadCfg64->Reserved1 = pLoadCfg32->Reserved1; - pLoadCfg64->CSDVersion = pLoadCfg32->CSDVersion; - pLoadCfg64->ProcessHeapFlags = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */ - pLoadCfg64->ProcessAffinityMask = pLoadCfg32->ProcessAffinityMask; - pLoadCfg64->VirtualMemoryThreshold = pLoadCfg32->VirtualMemoryThreshold; - pLoadCfg64->MaximumAllocationSize = pLoadCfg32->MaximumAllocationSize; - pLoadCfg64->LockPrefixTable = pLoadCfg32->LockPrefixTable; - pLoadCfg64->DeCommitTotalFreeThreshold = pLoadCfg32->DeCommitTotalFreeThreshold; - uint32_t u32DeCommitFreeBlockThreshold = pLoadCfg32->DeCommitFreeBlockThreshold; - pLoadCfg64->DeCommitFreeBlockThreshold = u32DeCommitFreeBlockThreshold; + pLoadCfg64->GuardAddressTakenIatEntryTable = pLoadCfg32->GuardAddressTakenIatEntryTable; + pLoadCfg64->GuardAddressTakenIatEntryCount = pLoadCfg32->GuardAddressTakenIatEntryCount; + pLoadCfg64->GuardLongJumpTargetTable = pLoadCfg32->GuardLongJumpTargetTable; + pLoadCfg64->GuardLongJumpTargetCount = pLoadCfg32->GuardLongJumpTargetCount; + pLoadCfg64->CodeIntegrity.Reserved = pLoadCfg32->CodeIntegrity.Reserved; + pLoadCfg64->CodeIntegrity.CatalogOffset = pLoadCfg32->CodeIntegrity.CatalogOffset; + pLoadCfg64->CodeIntegrity.Catalog = pLoadCfg32->CodeIntegrity.Catalog; + pLoadCfg64->CodeIntegrity.Flags = pLoadCfg32->CodeIntegrity.Flags; + pLoadCfg64->GuardFlags = pLoadCfg32->GuardFlags; + pLoadCfg64->GuardCFFunctionCount = pLoadCfg32->GuardCFFunctionCount; + pLoadCfg64->GuardCFFunctionTable = pLoadCfg32->GuardCFFunctionTable; + pLoadCfg64->Reserved2 = pLoadCfg32->Reserved2; + pLoadCfg64->GuardCFCCheckFunctionPointer = pLoadCfg32->GuardCFCCheckFunctionPointer; + pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; + pLoadCfg64->SEHandlerTable = pLoadCfg32->SEHandlerTable; + pLoadCfg64->SecurityCookie = pLoadCfg32->SecurityCookie; + pLoadCfg64->EditList = pLoadCfg32->EditList; + pLoadCfg64->Reserved1 = pLoadCfg32->Reserved1; + pLoadCfg64->CSDVersion = pLoadCfg32->CSDVersion; + pLoadCfg64->ProcessHeapFlags = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */ + pLoadCfg64->ProcessAffinityMask = pLoadCfg32->ProcessAffinityMask; + pLoadCfg64->VirtualMemoryThreshold = pLoadCfg32->VirtualMemoryThreshold; + pLoadCfg64->MaximumAllocationSize = pLoadCfg32->MaximumAllocationSize; + pLoadCfg64->LockPrefixTable = pLoadCfg32->LockPrefixTable; + pLoadCfg64->DeCommitTotalFreeThreshold = pLoadCfg32->DeCommitTotalFreeThreshold; + uint32_t u32DeCommitFreeBlockThreshold = pLoadCfg32->DeCommitFreeBlockThreshold; + pLoadCfg64->DeCommitFreeBlockThreshold = u32DeCommitFreeBlockThreshold; /* the rest is equal. */ Assert( RT_OFFSETOF(IMAGE_LOAD_CONFIG_DIRECTORY32, DeCommitFreeBlockThreshold) == RT_OFFSETOF(IMAGE_LOAD_CONFIG_DIRECTORY64, DeCommitFreeBlockThreshold)); @@ -3419,13 +3423,16 @@ * @param pModPe The PE module instance. * @param pOptHdr Pointer to the optional header (valid). * @param fFlags Loader flags, RTLDR_O_XXX. + * @param pErrInfo Where to return extended error information. Optional. */ -static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const IMAGE_OPTIONAL_HEADER64 *pOptHdr, uint32_t fFlags) +static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const IMAGE_OPTIONAL_HEADER64 *pOptHdr, uint32_t fFlags, + PRTERRINFO pErrInfo) { const char *pszLogName = pModPe->Core.pReader->pfnLogName(pModPe->Core.pReader); NOREF(pszLogName); union /* combine stuff we're reading to help reduce stack usage. */ { IMAGE_LOAD_CONFIG_DIRECTORY64 Cfg64; + uint8_t abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5) * 4]; } u; /* @@ -3436,6 +3443,9 @@ IMAGE_DATA_DIRECTORY Dir = pOptHdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG]; if (Dir.Size) { + const size_t cbExpectV5 = !pModPe->f64Bit + ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V5) + : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5); const size_t cbExpectV4 = !pModPe->f64Bit ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V4) : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V4); @@ -3449,77 +3459,103 @@ ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V1) : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/; - if ( Dir.Size != cbExpectV4 + bool fNewerStructureHack = false; + if ( Dir.Size != cbExpectV5 + && Dir.Size != cbExpectV4 && Dir.Size != cbExpectV3 && Dir.Size != cbExpectV2 && Dir.Size != cbExpectV1) { - Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %d bytes, expected %d, %d, %d, or %d.\n", - pszLogName, Dir.Size, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1)); - return VERR_LDRPE_LOAD_CONFIG_SIZE; + fNewerStructureHack = Dir.Size > cbExpectV5 /* These structure changes are slowly getting to us! More futher down. */ + && Dir.Size <= sizeof(u); + Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.%s\n", + pszLogName, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1, + fNewerStructureHack ? " Will try ignore extra bytes if all zero." : "")); + if (!fNewerStructureHack) + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, + "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu", + Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1); } /* - * Read and convert to 64-bit. + * Read, check new stuff and convert to 64-bit. + * + * If we accepted a newer structure, we check whether the new bits are + * all zero. This PRAYING/ASSUMING that the nothing new weird stuff is + * activated by a zero value and that it'll mostly be unused in areas + * we care about (which has been the case till now). */ RT_ZERO(u.Cfg64); int rc = rtldrPEReadRVA(pModPe, &u.Cfg64, Dir.Size, Dir.VirtualAddress); if (RT_FAILURE(rc)) return rc; + if ( fNewerStructureHack + && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5)) + { + Log(("rtldrPEOpen: %s: load cfg dir: Unexpected bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n", + pszLogName, Dir.Size, Dir.Size - cbExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5])); + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, + "Grown load config (%u to %u bytes) includes non-zero bytes: %.*Rhxs", + cbExpectV5, Dir.Size, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]); + } rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64); if (u.Cfg64.Size != Dir.Size) { - /* Kludge #1, seen ati shipping 32-bit DLLs and EXEs with Dir.Size=0x40 - and Cfg64.Size=0x5c or 0x48. Windows seems to deal with it, so - lets do so as well. */ - if ( Dir.Size < u.Cfg64.Size - && ( u.Cfg64.Size == cbExpectV3 - || u.Cfg64.Size == cbExpectV2) ) - { - Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the ATI kludge\n", - pszLogName, u.Cfg64.Size, Dir.Size)); - Dir.Size = u.Cfg64.Size; - RT_ZERO(u.Cfg64); - rc = rtldrPEReadRVA(pModPe, &u.Cfg64, Dir.Size, Dir.VirtualAddress); - if (RT_FAILURE(rc)) - return rc; - rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64); - } - - /* Kludge #2, ntdll.dll from XP seen with Dir.Size=0x40 and Cfg64.Size=0x00. */ + /* Kludge #1: ntdll.dll from XP seen with Dir.Size=0x40 and Cfg64.Size=0x00. */ if (Dir.Size == 0x40 && u.Cfg64.Size == 0x00 && !pModPe->f64Bit) { - Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the XP kludge\n", + Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the XP kludge.\n", pszLogName, u.Cfg64.Size, Dir.Size)); - u.Cfg64.Size = 0x40; + u.Cfg64.Size = Dir.Size; } - - /* Kludge #3, imagehlp.dll from W10/32 seen with Dir.Size=0x40 (V1) and Cfg64.Size=0x68 (V3). */ - if (Dir.Size == 0x40 && u.Cfg64.Size == 0x68 && !pModPe->f64Bit) + /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get + updated and stores some old size in the directory. Use the header size. */ + else if ( u.Cfg64.Size == cbExpectV5 + || u.Cfg64.Size == cbExpectV4 + || u.Cfg64.Size == cbExpectV3 + || u.Cfg64.Size == cbExpectV2 + || u.Cfg64.Size == cbExpectV1 + || (fNewerStructureHack = (u.Cfg64.Size > cbExpectV5 && u.Cfg64.Size <= sizeof(u))) ) { - Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the W10/32 kludge\n", + Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the old linker kludge.\n", pszLogName, u.Cfg64.Size, Dir.Size)); + Dir.Size = u.Cfg64.Size; + uint32_t const uOrgDir = Dir.Size; RT_ZERO(u.Cfg64); rc = rtldrPEReadRVA(pModPe, &u.Cfg64, Dir.Size, Dir.VirtualAddress); if (RT_FAILURE(rc)) return rc; + if ( fNewerStructureHack + && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5)) + { + Log(("rtldrPEOpen: %s: load cfg dir: Unknown bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n", + pszLogName, Dir.Size, Dir.Size - cbExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5])); + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, + "Grown load config (%u to %u bytes, dir %u) includes non-zero bytes: %.*Rhxs", + cbExpectV5, Dir.Size, uOrgDir, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]); + } rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64); + AssertReturn(u.Cfg64.Size == Dir.Size, + RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, "Data changed while reading! (%d vs %d)\n", + u.Cfg64.Size, Dir.Size)); } - - if (u.Cfg64.Size != Dir.Size) + else { - Log(("rtldrPEOpen: %s: load cfg dir: unexpected header size of %d bytes, expected %d.\n", - pszLogName, u.Cfg64.Size, Dir.Size)); - return VERR_LDRPE_LOAD_CONFIG_SIZE; + Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, or %zu.\n", + pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1)); + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, + "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, or %zu", + u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1); } } if (u.Cfg64.LockPrefixTable && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION))) { Log(("rtldrPEOpen: %s: load cfg dir: lock prefix table at %RX64. We don't support lock prefix tables!\n", pszLogName, u.Cfg64.LockPrefixTable)); - return VERR_LDRPE_LOCK_PREFIX_TABLE; + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOCK_PREFIX_TABLE, + "Lock prefix table not supported: %RX64", u.Cfg64.LockPrefixTable); } #if 0/* this seems to be safe to ignore. */ if ( u.Cfg64.SEHandlerTable @@ -3534,7 +3570,7 @@ { Log(("rtldrPEOpen: %s: load cfg dir: EditList=%RX64 is unsupported!\n", pszLogName, u.Cfg64.EditList)); - return VERR_BAD_EXE_FORMAT; + return RTErrInfoSetF(pErrInfo, VERR_BAD_EXE_FORMAT, "Load config EditList=%RX64 is not supported", u.Cfg64.EditList); } /** @todo GuardCFC? Possibly related to: * http://research.microsoft.com/pubs/69217/ccs05-cfi.pdf @@ -3544,13 +3580,24 @@ || u.Cfg64.Reserved2 || u.Cfg64.GuardCFFunctionTable || u.Cfg64.GuardCFFunctionCount - || u.Cfg64.GuardFlags) - && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION))) + || u.Cfg64.GuardFlags + || u.Cfg64.GuardAddressTakenIatEntryTable + || u.Cfg64.GuardAddressTakenIatEntryCount + || u.Cfg64.GuardLongJumpTargetTable + || u.Cfg64.GuardLongJumpTargetCount) + && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION)) ) { - Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32!\n", + Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!\n", pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2, - u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags)); - return VERR_BAD_EXE_FORMAT; + u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, + u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount, + u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount )); + return RTErrInfoSetF(pErrInfo, VERR_LDRPE_GUARD_CF_STUFF, + "Guard bits in load config: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!", + u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2, + u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, + u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount, + u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount); } } @@ -3577,14 +3624,20 @@ || pCur->dwLength + off > Dir.Size) { Log(("rtldrPEOpen: %s: cert at %#x/%#x: dwLength=%#x\n", pszLogName, off, Dir.Size, pCur->dwLength)); - rc = VERR_LDRPE_CERT_MALFORMED; + rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, + "Cert at %#x LB %#x: Bad header length value: %#x", off, Dir.Size, pCur->dwLength); break; } if ( pCur->wRevision != WIN_CERT_REVISION_2_0 && pCur->wRevision != WIN_CERT_REVISION_1_0) { Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); - rc = pCur->wRevision >= WIN_CERT_REVISION_1_0 ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; + if (pCur->wRevision >= WIN_CERT_REVISION_1_0) + rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_UNSUPPORTED, + "Cert at %#x LB %#x: Unsupported revision: %#x", off, Dir.Size, pCur->wRevision); + else + rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, + "Cert at %#x LB %#x: Malformed revision: %#x", off, Dir.Size, pCur->wRevision); break; } if ( pCur->wCertificateType != WIN_CERT_TYPE_PKCS_SIGNED_DATA @@ -3595,8 +3648,15 @@ && pCur->wCertificateType != WIN_CERT_TYPE_EFI_GUID ) { - Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); - rc = pCur->wCertificateType ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; + Log(("rtldrPEOpen: %s: cert at %#x/%#x: wCertificateType=%#x\n", pszLogName, off, Dir.Size, pCur->wCertificateType)); + if (pCur->wCertificateType) + rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_UNSUPPORTED, + "Cert at %#x LB %#x: Unsupported certificate type: %#x", + off, Dir.Size, pCur->wCertificateType); + else + rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, + "Cert at %#x LB %#x: Malformed certificate type: %#x", + off, Dir.Size, pCur->wCertificateType); break; } @@ -3760,7 +3820,7 @@ * inspection of the actual data. This also saves some certificate * information. */ - rc = rtldrPEValidateDirectoriesAndRememberStuff(pModPe, &OptHdr, fFlags); + rc = rtldrPEValidateDirectoriesAndRememberStuff(pModPe, &OptHdr, fFlags, pErrInfo); if (RT_SUCCESS(rc)) { *phLdrMod = &pModPe->Core; diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/math/bignum-amd64-x86.asm virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/math/bignum-amd64-x86.asm --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/common/math/bignum-amd64-x86.asm 2016-01-19 19:18:54.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/common/math/bignum-amd64-x86.asm 2016-08-22 14:20:37.000000000 +0000 @@ -25,11 +25,27 @@ ; +;********************************************************************************************************************************* +;* Header Files * +;********************************************************************************************************************************* %define RT_ASM_WITH_SEH64 %include "iprt/asmdefs.mac" %include "internal/bignum.mac" +;********************************************************************************************************************************* +;* Defined Constants And Macros * +;********************************************************************************************************************************* +%ifdef RT_ARCH_AMD64 + %macro sahf 0 + %error "SAHF not supported on ancient AMD64" + %endmacro + %macro lahf 0 + %error "LAHF not supported on ancient AMD64" + %endmacro +%endif + + BEGINCODE ;; @@ -66,10 +82,10 @@ %endif xor r11d, r11d ; index register. -%if RTBIGNUM_ELEMENT_SIZE == 4 + %if RTBIGNUM_ELEMENT_SIZE == 4 add cUsed, 1 ; cUsed = RT_ALIGN(cUsed, 2) / 2 shr cUsed, 1 -%endif + %endif cmp cUsed, 8 ; Skip the big loop if small number. jb .small_job @@ -105,12 +121,22 @@ dec r10d ; Does not change CF. jnz .big_loop + %if 0 ; Ancient AMD CPUs does have lahf/sahf, thus the mess in the %else. lahf ; Save CF and cUsed, 7 ; Up to seven odd rounds. jz .done sahf ; Restore CF. jmp .small_loop ; Skip CF=1 (clc). - + %else + jnc .no_carry + and cUsed, 7 ; Up to seven odd rounds. + jz .done + stc + jmp .small_loop ; Skip CF=1 (clc). +.no_carry: + and cUsed, 7 ; Up to seven odd rounds. + jz .done + %endif .small_job: clc .small_loop: @@ -246,10 +272,10 @@ %endif xor r11d, r11d ; index register. -%if RTBIGNUM_ELEMENT_SIZE == 4 + %if RTBIGNUM_ELEMENT_SIZE == 4 add cUsed, 1 ; cUsed = RT_ALIGN(cUsed, 2) / 2 shr cUsed, 1 -%endif + %endif cmp cUsed, 8 ; Skip the big loop if small number. jb .small_job @@ -277,12 +303,22 @@ dec r10d ; Does not change CF. jnz .big_loop + %if 0 ; Ancient AMD CPUs does have lahf/sahf, thus the mess in the %else. lahf ; Save CF and cUsed, 7 ; Up to seven odd rounds. jz .done sahf ; Restore CF. jmp .small_loop ; Skip CF=1 (clc). - + %else + jnc .no_carry + and cUsed, 7 ; Up to seven odd rounds. + jz .done + stc + jmp .small_loop ; Skip CF=1 (clc). +.no_carry: + and cUsed, 7 ; Up to seven odd rounds. + jz .done + %endif .small_job: clc .small_loop: @@ -450,7 +486,7 @@ jnz .big_loop ; More to do? - lahf ; save carry flag (uCarry no longer used on x86). + pushf ; save carry flag (uCarry no longer used on x86). %ifdef RT_ARCH_AMD64 mov cUsed, r11d %else @@ -458,10 +494,10 @@ %endif and cUsed, 7 jz .restore_cf_and_return ; Jump if we're good and done. - sahf ; Restore CF. + popf ; Restore CF. jmp .small_loop ; Deal with the odd rounds. .restore_cf_and_return: - sahf + popf jmp .carry_to_eax ; Small loop - One round at the time. diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/include/internal/ldrPE.h virtualbox-4.3.40-dfsg/src/VBox/Runtime/include/internal/ldrPE.h --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/include/internal/ldrPE.h 2016-01-19 19:18:59.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/include/internal/ldrPE.h 2016-08-22 14:20:42.000000000 +0000 @@ -669,9 +669,48 @@ typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V4; typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4; -typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 IMAGE_LOAD_CONFIG_DIRECTORY32; -typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V4 PIMAGE_LOAD_CONFIG_DIRECTORY32; -typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4 PCIMAGE_LOAD_CONFIG_DIRECTORY32; +/** @since Windows 10 build 10286 (or maybe earlier). */ +typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V5 +{ + uint32_t Size; + uint32_t TimeDateStamp; + uint16_t MajorVersion; + uint16_t MinorVersion; + uint32_t GlobalFlagsClear; + uint32_t GlobalFlagsSet; + uint32_t CriticalSectionDefaultTimeout; + uint32_t DeCommitFreeBlockThreshold; + uint32_t DeCommitTotalFreeThreshold; + uint32_t LockPrefixTable; + uint32_t MaximumAllocationSize; + uint32_t VirtualMemoryThreshold; + uint32_t ProcessHeapFlags; + uint32_t ProcessAffinityMask; + uint16_t CSDVersion; + uint16_t Reserved1; + uint32_t EditList; + uint32_t SecurityCookie; + uint32_t SEHandlerTable; + uint32_t SEHandlerCount; + uint32_t GuardCFCCheckFunctionPointer; + uint32_t Reserved2; + uint32_t GuardCFFunctionTable; + uint32_t GuardCFFunctionCount; + uint32_t GuardFlags; + IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; + uint32_t GuardAddressTakenIatEntryTable; + uint32_t GuardAddressTakenIatEntryCount; + uint32_t GuardLongJumpTargetTable; + uint32_t GuardLongJumpTargetCount; +} IMAGE_LOAD_CONFIG_DIRECTORY32_V5; +AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V5, 0x78); +typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V5; +typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5; + +typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 IMAGE_LOAD_CONFIG_DIRECTORY32; +typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V5 PIMAGE_LOAD_CONFIG_DIRECTORY32; +typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5 PCIMAGE_LOAD_CONFIG_DIRECTORY32; + /* No _IMAGE_LOAD_CONFIG_DIRECTORY64_V1 exists. */ @@ -770,9 +809,47 @@ typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V4; typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4; -typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 IMAGE_LOAD_CONFIG_DIRECTORY64; -typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V4 PIMAGE_LOAD_CONFIG_DIRECTORY64; -typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4 PCIMAGE_LOAD_CONFIG_DIRECTORY64; +/** @since Windows 10 build 10286 (or maybe earlier). */ +typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V5 +{ + uint32_t Size; + uint32_t TimeDateStamp; + uint16_t MajorVersion; + uint16_t MinorVersion; + uint32_t GlobalFlagsClear; + uint32_t GlobalFlagsSet; + uint32_t CriticalSectionDefaultTimeout; + uint64_t DeCommitFreeBlockThreshold; + uint64_t DeCommitTotalFreeThreshold; + uint64_t LockPrefixTable; + uint64_t MaximumAllocationSize; + uint64_t VirtualMemoryThreshold; + uint64_t ProcessAffinityMask; + uint32_t ProcessHeapFlags; + uint16_t CSDVersion; + uint16_t Reserved1; + uint64_t EditList; + uint64_t SecurityCookie; + uint64_t SEHandlerTable; + uint64_t SEHandlerCount; + uint64_t GuardCFCCheckFunctionPointer; + uint64_t Reserved2; + uint64_t GuardCFFunctionTable; + uint64_t GuardCFFunctionCount; + uint32_t GuardFlags; + IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; + uint64_t GuardAddressTakenIatEntryTable; + uint64_t GuardAddressTakenIatEntryCount; + uint64_t GuardLongJumpTargetTable; + uint64_t GuardLongJumpTargetCount; +} IMAGE_LOAD_CONFIG_DIRECTORY64_V5; +AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V5, 0xc0); +typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V5; +typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5; + +typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 IMAGE_LOAD_CONFIG_DIRECTORY64; +typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V5 PIMAGE_LOAD_CONFIG_DIRECTORY64; +typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5 PCIMAGE_LOAD_CONFIG_DIRECTORY64; typedef struct _IMAGE_DEBUG_DIRECTORY diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c virtualbox-4.3.40-dfsg/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c 2016-01-19 19:19:00.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c 2016-08-22 14:20:44.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Revision: 103354 $ */ +/* $Revision: 106552 $ */ /** @file * IPRT - Ring-0 Memory Objects, Linux. */ @@ -372,11 +372,17 @@ #endif /* < 2.4.22 */ pMemLnx->fContiguous = fContiguous; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) /* * Reserve the pages. + * + * Linux >= 4.5 with CONFIG_DEBUG_VM panics when setting PG_reserved on compound + * pages. According to Michal Hocko this shouldn't be necessary anyway because + * as pages which are not on the LRU list are never evictable. */ for (iPage = 0; iPage < cPages; iPage++) SetPageReserved(pMemLnx->apPages[iPage]); +#endif /* * Note that the physical address of memory allocated with alloc_pages(flags, order) @@ -423,7 +429,12 @@ */ while (iPage-- > 0) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) + /* + * See SetPageReserved() in rtR0MemObjLinuxAllocPages() + */ ClearPageReserved(pMemLnx->apPages[iPage]); +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) #else MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1); @@ -578,7 +589,11 @@ { if (!PageReserved(pMemLnx->apPages[iPage])) SetPageDirty(pMemLnx->apPages[iPage]); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) + put_page(pMemLnx->apPages[iPage]); +#else page_cache_release(pMemLnx->apPages[iPage]); +#endif } if (pTask && pTask->mm) @@ -1029,14 +1044,38 @@ /* * Get user pages. */ - rc = get_user_pages(pTask, /* Task for fault accounting. */ - pTask->mm, /* Whose pages. */ - R3Ptr, /* Where from. */ - cPages, /* How many pages. */ - fWrite, /* Write to memory. */ - fWrite, /* force write access. */ - &pMemLnx->apPages[0], /* Page array. */ - papVMAs); /* vmas */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) + if (R0Process == RTR0ProcHandleSelf()) + rc = get_user_pages(R3Ptr, /* Where from. */ + cPages, /* How many pages. */ + fWrite, /* Write to memory. */ + fWrite, /* force write access. */ + &pMemLnx->apPages[0], /* Page array. */ + papVMAs); /* vmas */ + /* + * Actually this should not happen at the moment as call this function + * only for our own process. + */ + else + rc = get_user_pages_remote( + pTask, /* Task for fault accounting. */ + pTask->mm, /* Whose pages. */ + R3Ptr, /* Where from. */ + cPages, /* How many pages. */ + fWrite, /* Write to memory. */ + fWrite, /* force write access. */ + &pMemLnx->apPages[0], /* Page array. */ + papVMAs); /* vmas */ +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) */ + rc = get_user_pages(pTask, /* Task for fault accounting. */ + pTask->mm, /* Whose pages. */ + R3Ptr, /* Where from. */ + cPages, /* How many pages. */ + fWrite, /* Write to memory. */ + fWrite, /* force write access. */ + &pMemLnx->apPages[0], /* Page array. */ + papVMAs); /* vmas */ +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) */ if (rc == cPages) { /* @@ -1081,7 +1120,11 @@ { if (!PageReserved(pMemLnx->apPages[rc])) SetPageDirty(pMemLnx->apPages[rc]); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) + put_page(pMemLnx->apPages[rc]); +#else page_cache_release(pMemLnx->apPages[rc]); +#endif } up_read(&pTask->mm->mmap_sem); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp 2016-01-19 19:19:02.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp 2016-08-22 14:20:45.000000000 +0000 @@ -345,7 +345,8 @@ } if (!NT_SUCCESS(rcNt)) { - if (rcNt == STATUS_NO_MORE_FILES || rcNt == STATUS_NO_MORE_ENTRIES) + /* Note! VBoxSVR and CIFS file systems both ends up with STATUS_NO_SUCH_FILE here instead of STATUS_NO_MORE_FILES. */ + if (rcNt == STATUS_NO_MORE_FILES || rcNt == STATUS_NO_MORE_ENTRIES || rcNt == STATUS_NO_SUCH_FILE) return VERR_NO_MORE_FILES; return RTErrConvertFromNtStatus(rcNt); } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/sched-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/sched-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/sched-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/sched-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -392,6 +392,7 @@ rc = pthread_create(&Thread, &ThreadAttr, pfnThread, pvArg); if (!rc) { + pthread_attr_destroy(&ThreadAttr); /* * Wait for the thread to finish. */ diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -140,44 +140,37 @@ /* * Create the semaphore. */ - pthread_mutexattr_t MutexAttr; - rc = pthread_mutexattr_init(&MutexAttr); + rc = pthread_mutex_init(&pThis->Mutex, NULL); if (!rc) { - rc = pthread_mutex_init(&pThis->Mutex, &MutexAttr); - if (!rc) - { - pthread_mutexattr_destroy(&MutexAttr); - pthread_condattr_destroy(&CondAttr); + pthread_condattr_destroy(&CondAttr); - ASMAtomicXchgU32(&pThis->u32State, EVENTMULTI_STATE_NOT_SIGNALED); - ASMAtomicXchgU32(&pThis->cWaiters, 0); + ASMAtomicXchgU32(&pThis->u32State, EVENTMULTI_STATE_NOT_SIGNALED); + ASMAtomicXchgU32(&pThis->cWaiters, 0); #ifdef RTSEMEVENTMULTI_STRICT - if (!pszNameFmt) - { - static uint32_t volatile s_iSemEventMultiAnon = 0; - RTLockValidatorRecSharedInit(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, - true /*fSignaller*/, !(fFlags & RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), - "RTSemEventMulti-%u", ASMAtomicIncU32(&s_iSemEventMultiAnon) - 1); - } - else - { - va_list va; - va_start(va, pszNameFmt); - RTLockValidatorRecSharedInitV(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, - true /*fSignaller*/, !(fFlags & RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), - pszNameFmt, va); - va_end(va); - } - pThis->fEverHadSignallers = false; -#endif - - *phEventMultiSem = pThis; - return VINF_SUCCESS; + if (!pszNameFmt) + { + static uint32_t volatile s_iSemEventMultiAnon = 0; + RTLockValidatorRecSharedInit(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, + true /*fSignaller*/, !(fFlags & RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), + "RTSemEventMulti-%u", ASMAtomicIncU32(&s_iSemEventMultiAnon) - 1); } + else + { + va_list va; + va_start(va, pszNameFmt); + RTLockValidatorRecSharedInitV(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, + true /*fSignaller*/, !(fFlags & RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), + pszNameFmt, va); + va_end(va); + } + pThis->fEverHadSignallers = false; +#endif - pthread_mutexattr_destroy(&MutexAttr); + *phEventMultiSem = pThis; + return VINF_SUCCESS; } + pthread_cond_destroy(&pThis->Cond); } pthread_condattr_destroy(&CondAttr); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semevent-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semevent-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semevent-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semevent-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -119,58 +119,42 @@ /* * Create the condition variable. */ - pthread_condattr_t CondAttr; - rc = pthread_condattr_init(&CondAttr); + rc = pthread_cond_init(&pThis->Cond, NULL); if (!rc) { - rc = pthread_cond_init(&pThis->Cond, &CondAttr); + /* + * Create the semaphore. + */ + rc = pthread_mutex_init(&pThis->Mutex, NULL); if (!rc) { - /* - * Create the semaphore. - */ - pthread_mutexattr_t MutexAttr; - rc = pthread_mutexattr_init(&MutexAttr); - if (!rc) - { - rc = pthread_mutex_init(&pThis->Mutex, &MutexAttr); - if (!rc) - { - pthread_mutexattr_destroy(&MutexAttr); - pthread_condattr_destroy(&CondAttr); - - ASMAtomicWriteU32(&pThis->u32State, EVENT_STATE_NOT_SIGNALED); - ASMAtomicWriteU32(&pThis->cWaiters, 0); - pThis->fFlags = fFlags; + ASMAtomicWriteU32(&pThis->u32State, EVENT_STATE_NOT_SIGNALED); + ASMAtomicWriteU32(&pThis->cWaiters, 0); + pThis->fFlags = fFlags; #ifdef RTSEMEVENT_STRICT - if (!pszNameFmt) - { - static uint32_t volatile s_iSemEventAnon = 0; - RTLockValidatorRecSharedInit(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, - true /*fSignaller*/, !(fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL), - "RTSemEvent-%u", ASMAtomicIncU32(&s_iSemEventAnon) - 1); - } - else - { - va_list va; - va_start(va, pszNameFmt); - RTLockValidatorRecSharedInitV(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, - true /*fSignaller*/, !(fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL), - pszNameFmt, va); - va_end(va); - } - pThis->fEverHadSignallers = false; + if (!pszNameFmt) + { + static uint32_t volatile s_iSemEventAnon = 0; + RTLockValidatorRecSharedInit(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, + true /*fSignaller*/, !(fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL), + "RTSemEvent-%u", ASMAtomicIncU32(&s_iSemEventAnon) - 1); + } + else + { + va_list va; + va_start(va, pszNameFmt); + RTLockValidatorRecSharedInitV(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis, + true /*fSignaller*/, !(fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL), + pszNameFmt, va); + va_end(va); + } + pThis->fEverHadSignallers = false; #endif - *phEventSem = pThis; - return VINF_SUCCESS; - } - - pthread_mutexattr_destroy(&MutexAttr); - } - pthread_cond_destroy(&pThis->Cond); + *phEventSem = pThis; + return VINF_SUCCESS; } - pthread_condattr_destroy(&CondAttr); + pthread_cond_destroy(&pThis->Cond); } rc = RTErrConvertFromErrno(rc); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semmutex-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semmutex-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semmutex-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semmutex-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2012 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -125,40 +125,32 @@ /* * Create the semaphore. */ - pthread_mutexattr_t MutexAttr; - rc = pthread_mutexattr_init(&MutexAttr); + rc = pthread_mutex_init(&pThis->Mutex, NULL); if (!rc) { - rc = pthread_mutex_init(&pThis->Mutex, &MutexAttr); - if (!rc) - { - pthread_mutexattr_destroy(&MutexAttr); - - pThis->Owner = (pthread_t)-1; - pThis->cNesting = 0; - pThis->u32Magic = RTSEMMUTEX_MAGIC; + pThis->Owner = (pthread_t)-1; + pThis->cNesting = 0; + pThis->u32Magic = RTSEMMUTEX_MAGIC; #ifdef RTSEMMUTEX_STRICT - if (!pszNameFmt) - { - static uint32_t volatile s_iMutexAnon = 0; - RTLockValidatorRecExclInit(&pThis->ValidatorRec, hClass, uSubClass, pThis, - !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), - "RTSemMutex-%u", ASMAtomicIncU32(&s_iMutexAnon) - 1); - } - else - { - va_list va; - va_start(va, pszNameFmt); - RTLockValidatorRecExclInitV(&pThis->ValidatorRec, hClass, uSubClass, pThis, - !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), pszNameFmt, va); - va_end(va); - } + if (!pszNameFmt) + { + static uint32_t volatile s_iMutexAnon = 0; + RTLockValidatorRecExclInit(&pThis->ValidatorRec, hClass, uSubClass, pThis, + !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), + "RTSemMutex-%u", ASMAtomicIncU32(&s_iMutexAnon) - 1); + } + else + { + va_list va; + va_start(va, pszNameFmt); + RTLockValidatorRecExclInitV(&pThis->ValidatorRec, hClass, uSubClass, pThis, + !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), pszNameFmt, va); + va_end(va); + } #endif - *phMutexSem = pThis; - return VINF_SUCCESS; - } - pthread_mutexattr_destroy(&MutexAttr); + *phMutexSem = pThis; + return VINF_SUCCESS; } RTMemFree(pThis); } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semrw-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semrw-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/semrw-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/semrw-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -111,46 +111,41 @@ /* * Create the rwlock. */ - pthread_rwlockattr_t Attr; - rc = pthread_rwlockattr_init(&Attr); + rc = pthread_rwlock_init(&pThis->RWLock, NULL); if (!rc) { - rc = pthread_rwlock_init(&pThis->RWLock, &Attr); - if (!rc) - { - pThis->u32Magic = RTSEMRW_MAGIC; - pThis->cReaders = 0; - pThis->cWrites = 0; - pThis->cWriterReads = 0; - pThis->Writer = (pthread_t)-1; + pThis->u32Magic = RTSEMRW_MAGIC; + pThis->cReaders = 0; + pThis->cWrites = 0; + pThis->cWriterReads = 0; + pThis->Writer = (pthread_t)-1; #ifdef RTSEMRW_STRICT - bool const fLVEnabled = !(fFlags & RTSEMRW_FLAGS_NO_LOCK_VAL); - if (!pszNameFmt) - { - static uint32_t volatile s_iSemRWAnon = 0; - uint32_t i = ASMAtomicIncU32(&s_iSemRWAnon) - 1; - RTLockValidatorRecExclInit(&pThis->ValidatorWrite, hClass, uSubClass, pThis, - fLVEnabled, "RTSemRW-%u", i); - RTLockValidatorRecSharedInit(&pThis->ValidatorRead, hClass, uSubClass, pThis, - false /*fSignaller*/, fLVEnabled, "RTSemRW-%u", i); - } - else - { - va_list va; - va_start(va, pszNameFmt); - RTLockValidatorRecExclInitV(&pThis->ValidatorWrite, hClass, uSubClass, pThis, - fLVEnabled, pszNameFmt, va); - va_end(va); - va_start(va, pszNameFmt); - RTLockValidatorRecSharedInitV(&pThis->ValidatorRead, hClass, uSubClass, pThis, - false /*fSignaller*/, fLVEnabled, pszNameFmt, va); - va_end(va); - } - RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core); -#endif - *phRWSem = pThis; - return VINF_SUCCESS; + bool const fLVEnabled = !(fFlags & RTSEMRW_FLAGS_NO_LOCK_VAL); + if (!pszNameFmt) + { + static uint32_t volatile s_iSemRWAnon = 0; + uint32_t i = ASMAtomicIncU32(&s_iSemRWAnon) - 1; + RTLockValidatorRecExclInit(&pThis->ValidatorWrite, hClass, uSubClass, pThis, + fLVEnabled, "RTSemRW-%u", i); + RTLockValidatorRecSharedInit(&pThis->ValidatorRead, hClass, uSubClass, pThis, + false /*fSignaller*/, fLVEnabled, "RTSemRW-%u", i); } + else + { + va_list va; + va_start(va, pszNameFmt); + RTLockValidatorRecExclInitV(&pThis->ValidatorWrite, hClass, uSubClass, pThis, + fLVEnabled, pszNameFmt, va); + va_end(va); + va_start(va, pszNameFmt); + RTLockValidatorRecSharedInitV(&pThis->ValidatorRead, hClass, uSubClass, pThis, + false /*fSignaller*/, fLVEnabled, pszNameFmt, va); + va_end(va); + } + RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core); +#endif + *phRWSem = pThis; + return VINF_SUCCESS; } rc = RTErrConvertFromErrno(rc); diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/thread-posix.cpp virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/thread-posix.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/posix/thread-posix.cpp 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/posix/thread-posix.cpp 2016-08-22 14:20:46.000000000 +0000 @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2013 Oracle Corporation + * Copyright (C) 2006-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -361,6 +361,7 @@ rc = pthread_create(&ThreadId, &ThreadAttr, rtThreadNativeMain, pThread); if (!rc) { + pthread_attr_destroy(&ThreadAttr); *pNativeThread = (uintptr_t)ThreadId; return VINF_SUCCESS; } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/win/VBoxRT-openssl.def virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/win/VBoxRT-openssl.def --- virtualbox-4.3.36-dfsg/src/VBox/Runtime/r3/win/VBoxRT-openssl.def 2016-01-19 19:19:03.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Runtime/r3/win/VBoxRT-openssl.def 2016-08-22 14:20:47.000000000 +0000 @@ -3113,34 +3113,6 @@ SSL_version SSL_want SSL_write - ssl2_accept - ssl2_callback_ctrl - ssl2_clear - ssl2_connect - ssl2_ctrl - ssl2_ctx_callback_ctrl - ssl2_ctx_ctrl - ssl2_default_timeout - ssl2_do_write - ssl2_enc - ssl2_enc_init - ssl2_free - ssl2_generate_key_material - ssl2_get_cipher - ssl2_get_cipher_by_char - ssl2_mac - ssl2_new - ssl2_num_ciphers - ssl2_part_read - ssl2_peek - ssl2_pending - ssl2_put_cipher_by_char - ssl2_read - ssl2_return_error - ssl2_set_certificate - ssl2_shutdown - ssl2_write - ssl2_write_error ssl23_accept ssl23_connect ssl23_default_timeout @@ -3242,9 +3214,6 @@ ssl3_write ssl3_write_bytes ssl3_write_pending - SSLv2_client_method - SSLv2_method - SSLv2_server_method SSLv23_client_method SSLv23_method SSLv23_server_method diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Storage/ISCSI.cpp virtualbox-4.3.40-dfsg/src/VBox/Storage/ISCSI.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Storage/ISCSI.cpp 2016-01-19 19:19:07.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Storage/ISCSI.cpp 2016-08-22 14:20:50.000000000 +0000 @@ -604,6 +604,11 @@ unsigned cCmdsWaiting; /** Table of commands waiting for a response from the target. */ PISCSICMD aCmdsWaiting[ISCSI_CMD_WAITING_ENTRIES]; + /** Number of logins since last successful I/O. + * Used to catch the case where logging succeeds but + * processing read/write/flushes cause a disconnect. + */ + volatile uint32_t cLoginsSinceIo; /** Release log counter. */ unsigned cLogRelErrors; @@ -1221,6 +1226,13 @@ Assert(pImage->state == ISCSISTATE_FREE); + /* + * If there were too many logins without any successful I/O just fail + * and assume the target is not working properly. + */ + if (ASMAtomicReadU32(&pImage->cLoginsSinceIo) == 3) + return VERR_BROKEN_PIPE; + RTSemMutexRequest(pImage->Mutex, RT_INDEFINITE_WAIT); /* Make 100% sure the connection isn't reused for a new login. */ @@ -1662,6 +1674,9 @@ else pImage->state = ISCSISTATE_NORMAL; + if (RT_SUCCESS(rc)) + ASMAtomicIncU32(&pImage->cLoginsSinceIo); + RTSemMutexRelease(pImage->Mutex); LogFlowFunc(("returning %Rrc\n", rc)); @@ -1989,6 +2004,8 @@ RTSemMutexRelease(pImage->Mutex); out: + if (RT_SUCCESS(rc)) + ASMAtomicWriteU32(&pImage->cLoginsSinceIo, 0); LogFlowFunc(("returns %Rrc\n", rc)); return rc; } @@ -3222,23 +3239,18 @@ } /** - * Reattaches the to the target after an error aborting - * pending commands and resending them. + * Clears all RX/TX PDU states and returns the command for the current + * pending TX PDU if existing. * - * @param pImage iSCSI connection state. + * @returns Pointer to the iSCSI command for the current PDU transmitted or NULL + * if none is waiting. + * @param pImage iSCSI connection state. */ -static void iscsiReattach(PISCSIIMAGE pImage) +static PISCSICMD iscsiPDURxTxClear(PISCSIIMAGE pImage) { - int rc = VINF_SUCCESS; PISCSICMD pIScsiCmdHead = NULL; - PISCSICMD pIScsiCmd = NULL; - PISCSICMD pIScsiCmdCur = NULL; PISCSIPDUTX pIScsiPDUTx = NULL; - /* Close connection. */ - iscsiTransportClose(pImage); - pImage->state = ISCSISTATE_FREE; - /* Reset PDU we are receiving. */ iscsiRecvPDUReset(pImage); @@ -3251,8 +3263,7 @@ pIScsiPDUTx = pImage->pIScsiPDUTxHead; pImage->pIScsiPDUTxHead = pIScsiPDUTx->pNext; - pIScsiCmd = pIScsiPDUTx->pIScsiCmd; - + PISCSICMD pIScsiCmd = pIScsiPDUTx->pIScsiCmd; if (pIScsiCmd) { /* Place on command list. */ @@ -3271,8 +3282,7 @@ pIScsiPDUTx = pImage->pIScsiPDUTxCur; pImage->pIScsiPDUTxCur = NULL; - pIScsiCmd = pIScsiPDUTx->pIScsiCmd; - + PISCSICMD pIScsiCmd = pIScsiPDUTx->pIScsiCmd; if (pIScsiCmd) { pIScsiCmd->pNext = pIScsiCmdHead; @@ -3281,12 +3291,29 @@ RTMemFree(pIScsiPDUTx); } + return pIScsiCmdHead; +} + +/** + * Rests the iSCSI connection state and returns a list of iSCSI commands pending + * when this was called. + * + * @returns Pointer to the head of the pending iSCSI command list. + * @param pImage iSCSI connection state. + */ +static PISCSICMD iscsiReset(PISCSIIMAGE pImage) +{ + PISCSICMD pIScsiCmdHead = NULL; + PISCSICMD pIScsiCmdCur = NULL; + + /* Clear all in flight PDUs. */ + pIScsiCmdHead = iscsiPDURxTxClear(pImage); + /* * Get all commands which are waiting for a response * They need to be resend too after a successful reconnect. */ - pIScsiCmd = iscsiCmdRemoveAll(pImage); - + PISCSICMD pIScsiCmd = iscsiCmdRemoveAll(pImage); if (pIScsiCmd) { pIScsiCmdCur = pIScsiCmd; @@ -3301,8 +3328,26 @@ pIScsiCmdHead = pIScsiCmd; } + return pIScsiCmdHead; +} + +/** + * Reattaches the to the target after an error aborting + * pending commands and resending them. + * + * @param pImage iSCSI connection state. + */ +static void iscsiReattach(PISCSIIMAGE pImage) +{ + /* Close connection. */ + iscsiTransportClose(pImage); + pImage->state = ISCSISTATE_FREE; + + /* Reset the state and get the currently pending commands. */ + PISCSICMD pIScsiCmdHead = iscsiReset(pImage); + /* Try to attach. */ - rc = iscsiAttach(pImage); + int rc = iscsiAttach(pImage); if (RT_SUCCESS(rc)) { /* Phew, we have a connection again. @@ -3310,16 +3355,35 @@ */ while (pIScsiCmdHead) { - pIScsiCmd = pIScsiCmdHead; + PISCSICMD pIScsiCmd = pIScsiCmdHead; pIScsiCmdHead = pIScsiCmdHead->pNext; pIScsiCmd->pNext = NULL; rc = iscsiPDUTxPrepare(pImage, pIScsiCmd); - AssertRC(rc); + if (RT_FAILURE(rc)) + break; + } + + if (RT_FAILURE(rc)) + { + /* Another error, just give up and report an error. */ + PISCSICMD pIScsiCmd = iscsiReset(pImage); + + /* Concatenate both lists together so we can abort all requests below. */ + if (pIScsiCmd) + { + PISCSICMD pIScsiCmdCur = pIScsiCmd; + while (pIScsiCmdCur->pNext) + pIScsiCmdCur = pIScsiCmdCur->pNext; + + pIScsiCmdCur->pNext = pIScsiCmdHead; + pIScsiCmdHead = pIScsiCmd; + } } } - else + + if (RT_FAILURE(rc)) { /* * Still no luck, complete commands with error so the caller @@ -3327,7 +3391,7 @@ */ while (pIScsiCmdHead) { - pIScsiCmd = pIScsiCmdHead; + PISCSICMD pIScsiCmd = pIScsiCmdHead; pIScsiCmdHead = pIScsiCmdHead->pNext; iscsiCmdComplete(pImage, pIScsiCmd, VERR_BROKEN_PIPE); @@ -3383,7 +3447,8 @@ if (RT_LIKELY(iscsiIsClientConnected(pImage))) { rc = iscsiPDUTxPrepare(pImage, pIScsiCmd); - AssertRC(rc); + if (RT_FAILURE(rc)) + iscsiReattach(pImage); } else iscsiCmdComplete(pImage, pIScsiCmd, VERR_NET_CONNECTION_REFUSED); @@ -3631,6 +3696,9 @@ size_t cbTransfered = 0; PSCSIREQ pScsiReq = (PSCSIREQ)pvUser; + if (RT_SUCCESS(rcReq)) + ASMAtomicWriteU32(&pImage->cLoginsSinceIo, 0); + if ( RT_SUCCESS(rcReq) && pScsiReq->cbSense > 0) { @@ -3714,6 +3782,11 @@ RTMemFree(pImage->pszTargetName); pImage->pszTargetName = NULL; } + if (pImage->pszTargetAddress) + { + RTMemFree(pImage->pszTargetAddress); + pImage->pszTargetAddress = NULL; + } if (pImage->pszInitiatorName) { if (pImage->fAutomaticInitiatorName) @@ -3747,6 +3820,11 @@ RTMemFree(pImage->pvRecvPDUBuf); pImage->pvRecvPDUBuf = NULL; } + if (pImage->pszHostname) + { + RTMemFree(pImage->pszHostname); + pImage->pszHostname = NULL; + } pImage->cbRecvPDUResidual = 0; } @@ -3811,6 +3889,7 @@ pImage->ISID = 0x800000000000ULL | 0x001234560000ULL; pImage->cISCSIRetries = 10; pImage->state = ISCSISTATE_FREE; + pImage->cLoginsSinceIo = 0; pImage->pvRecvPDUBuf = RTMemAlloc(ISCSI_RECV_PDU_BUFFER_SIZE); pImage->cbRecvPDUBuf = ISCSI_RECV_PDU_BUFFER_SIZE; if (pImage->pvRecvPDUBuf == NULL) @@ -4107,7 +4186,7 @@ if (RT_FAILURE(rc)) { LogRel(("iSCSI: Could not get LUN info for target %s, rc=%Rrc\n", pImage->pszTargetName, rc)); - return rc; + goto out; } /* @@ -4472,6 +4551,8 @@ } out: + if (pszLUNInitial) + RTMemFree(pszLUNInitial); if (RT_FAILURE(rc)) iscsiFreeImage(pImage, false); return rc; diff -Nru virtualbox-4.3.36-dfsg/src/VBox/Storage/VDI.cpp virtualbox-4.3.40-dfsg/src/VBox/Storage/VDI.cpp --- virtualbox-4.3.36-dfsg/src/VBox/Storage/VDI.cpp 2016-01-19 19:19:07.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/Storage/VDI.cpp 2016-08-22 14:20:50.000000000 +0000 @@ -2671,7 +2671,7 @@ uint64_t cbBlockspaceNew = cBlocksNew * sizeof(VDIIMAGEBLOCKPOINTER); /** < Required space for the block array after the resize. */ uint64_t offStartDataNew = RT_ALIGN_32(pImage->offStartBlocks + cbBlockspaceNew, VDI_DATA_ALIGN); /** < New start offset for block data after the resize */ - if ( pImage->offStartData != offStartDataNew + if ( pImage->offStartData < offStartDataNew && cBlocksAllocated > 0) { /* Calculate how many sectors need to be relocated. */ diff -Nru virtualbox-4.3.36-dfsg/src/VBox/VMM/VMMR0/HMSVMR0.cpp virtualbox-4.3.40-dfsg/src/VBox/VMM/VMMR0/HMSVMR0.cpp --- virtualbox-4.3.36-dfsg/src/VBox/VMM/VMMR0/HMSVMR0.cpp 2016-01-19 19:19:08.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/VMM/VMMR0/HMSVMR0.cpp 2016-08-22 14:20:51.000000000 +0000 @@ -5031,6 +5031,7 @@ Event.n.u1Valid = 1; Event.n.u3Type = SVM_EVENT_EXCEPTION; Event.n.u8Vector = X86_XCPT_AC; + Event.n.u1ErrorCodeValid = 1; hmR0SvmSetPendingEvent(pVCpu, &Event, 0 /* GCPtrFaultAddress */); return VINF_SUCCESS; } diff -Nru virtualbox-4.3.36-dfsg/src/VBox/VMM/VMMR3/CPUMR3Db.cpp virtualbox-4.3.40-dfsg/src/VBox/VMM/VMMR3/CPUMR3Db.cpp --- virtualbox-4.3.36-dfsg/src/VBox/VMM/VMMR3/CPUMR3Db.cpp 2016-01-19 19:19:09.000000000 +0000 +++ virtualbox-4.3.40-dfsg/src/VBox/VMM/VMMR3/CPUMR3Db.cpp 2016-08-22 14:20:52.000000000 +0000 @@ -489,6 +489,11 @@ * A typical example is a VM that has been moved between different hosts where * for instance the cpu vendor differs. * + * Another example is older CPU profiles (e.g. Atom Bonnet) for newer CPUs (e.g. + * Atom Silvermont), where features reported thru CPUID aren't present in the + * MSRs (e.g. AMD64_TSC_AUX). + * + * * @returns VBox status code. * @param pVM Pointer to the cross context VM structure. */ @@ -533,6 +538,16 @@ AssertLogRelRCReturn(rc, rc); } + if (pVM->cpum.s.GuestFeatures.fRdTscP) + { + static CPUMMSRRANGE const s_aRdTscPFudgeMsrs[] = + { + MFX(0xc0000103, "AMD64_TSC_AUX", Amd64TscAux, Amd64TscAux, 0, 0, ~(uint64_t)UINT32_MAX), + }; + rc = cpumR3MsrApplyFudgeTable(pVM, &s_aRdTscPFudgeMsrs[0], RT_ELEMENTS(s_aRdTscPFudgeMsrs)); + AssertLogRelRCReturn(rc, rc); + } + return rc; }