Index: branches/2017Q4/emulators/xen-kernel/Makefile =================================================================== --- branches/2017Q4/emulators/xen-kernel/Makefile (revision 452769) +++ branches/2017Q4/emulators/xen-kernel/Makefile (revision 452770) @@ -1,111 +1,112 @@ # $FreeBSD$ PORTNAME= xen PORTVERSION= 4.7.2 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= emulators MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/ PKGNAMESUFFIX= -kernel MAINTAINER= royger@FreeBSD.org COMMENT= Hypervisor using a microkernel design LICENSE= GPLv2 ONLY_FOR_ARCHS= amd64 USES= cpe gmake python:build # We need to use ld from ports because the version in base doesn't # support the '--build-id' switch that's needed for live hypervisor # hot-patching. Once the ld version in base supports this option the # dependency can be removed. # # GNU objcopy is used instead of elftc objcopy because of bug #533: # https://sourceforge.net/p/elftoolchain/tickets/533/ # Once this is solved we should be able to switch to elfcopy. # # And finally we also need to use nm from binutils because the one # from base cannot deal with i386pep binary files which is the format # of the Xen EFI image (note that FreeBSD cannot yet boot as Dom0 from EFI, # but the image is built anyway). This is reported to elftc as bug #534: # https://sourceforge.net/p/elftoolchain/tickets/534/ MAKE_ARGS= clang=y PYTHON=${PYTHON_CMD} LD="${LD}" OBJCOPY="${OBJCOPY}" \ NM="${NM}" USE_BINUTILS= yes NO_MTREE= yes STRIP= # PLIST_FILES= /boot/xen \ /boot/xen.4th EXTRA_PATCHES= ${FILESDIR}/0001-xen-logdirty-prevent-preemption-if-finished.patch:-p1 \ ${FILESDIR}/0002-xen-rework-paging_log_dirty_op-to-work-with-hvm-gues.patch:-p1 \ ${FILESDIR}/kconf_arch.patch:-p1 \ ${FILESDIR}/0001-x86-drop-unneeded-__packed-attributes.patch:-p1 \ ${FILESDIR}/0002-build-clang-fix-XSM-dummy-policy-when-using-clang-4..patch:-p1 \ ${FILESDIR}/xsa212.patch:-p1 \ ${FILESDIR}/xsa213-4.7.patch:-p1 \ ${FILESDIR}/xsa214.patch:-p1 \ ${FILESDIR}/xsa215.patch:-p1 \ ${FILESDIR}/xsa217.patch:-p1 \ ${FILESDIR}/0001-IOMMU-handle-IOMMU-mapping-and-unmapping-failures.patch:-p1 \ ${FILESDIR}/0002-gnttab-fix-unmap-pin-accounting-race.patch:-p1 \ ${FILESDIR}/0003-gnttab-Avoid-potential-double-put-of-maptrack-entry.patch:-p1 \ ${FILESDIR}/0004-gnttab-correct-maptrack-table-accesses.patch:-p1 \ ${FILESDIR}/xsa219-4.8.patch:-p1 \ ${FILESDIR}/xsa220-4.7.patch:-p1 \ ${FILESDIR}/xsa221.patch:-p1 \ ${FILESDIR}/xsa222-1-4.7.patch:-p1 \ ${FILESDIR}/xsa222-2-4.7.patch:-p1 \ ${FILESDIR}/0001-gnttab-Fix-handling-of-dev_bus_addr-during-unmap.patch:-p1 \ ${FILESDIR}/0002-gnttab-never-create-host-mapping-unless-asked-to.patch:-p1 \ ${FILESDIR}/0003-gnttab-correct-logic-to-get-page-references-during-m.patch:-p1 \ ${FILESDIR}/0004-gnttab-__gnttab_unmap_common_complete-is-all-or-noth.patch:-p1 \ ${FILESDIR}/xsa226-4.7.patch:-p1 \ ${FILESDIR}/xsa227.patch:-p1 \ ${FILESDIR}/xsa228-4.8.patch:-p1 \ ${FILESDIR}/xsa230.patch:-p1 \ ${FILESDIR}/xsa231-4.7.patch:-p1 \ ${FILESDIR}/xsa232.patch:-p1 \ ${FILESDIR}/xsa233.patch:-p1 \ ${FILESDIR}/xsa234-4.8.patch:-p1 \ ${FILESDIR}/0001-x86-dont-allow-MSI-pIRQ-mapping-on-unowned-device.patch:-p1 \ ${FILESDIR}/0002-x86-enforce-proper-privilege-when-mapping-pIRQ-s.patch:-p1 \ ${FILESDIR}/0003-x86-MSI-disallow-redundant-enabling.patch:-p1 \ ${FILESDIR}/0004-x86-IRQ-conditionally-preserve-irq-pirq-mapping-on-error.patch:-p1 \ ${FILESDIR}/0005-x86-FLASK-fix-unmap-domain-IRQ-XSM-hook.patch:-p1 \ ${FILESDIR}/xsa238.patch:-p1 \ ${FILESDIR}/xsa239.patch:-p1 \ ${FILESDIR}/0001-x86-limit-linear-page-table-use-to-a-single-level.patch:-p1 \ ${FILESDIR}/0002-x86-mm-Disable-PV-linear-pagetables-by-default.patch:-p1 \ ${FILESDIR}/xsa241-4.8.patch:-p1 \ ${FILESDIR}/xsa242-4.9.patch:-p1 \ ${FILESDIR}/xsa243-4.7.patch:-p1 \ - ${FILESDIR}/xsa244-4.7.patch:-p1 + ${FILESDIR}/xsa244-4.7.patch:-p1 \ + ${FILESDIR}/xsa236-4.9.patch:-p1 .include .if ${OPSYS} != FreeBSD IGNORE= only supported on FreeBSD .endif .if ${OSVERSION} < 1100055 IGNORE= only supported on recent FreeBSD 11 .endif pre-build: ${MAKE_CMD} -C ${WRKSRC}/xen defconfig ${MAKE_ARGS} # Enable hypervisor hot-patching. echo 'CONFIG_XSPLICE=y' >> ${WRKSRC}/xen/.config echo 'CONFIG_FAST_SYMBOL_LOOKUP=y' >> ${WRKSRC}/xen/.config # The ports native 'build' target cannot be used because it sets # CFLAGS, and that breaks the Xen build system. do-build: ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -C ${WRKSRC}/xen build ${MAKE_ARGS} do-install: ${MKDIR} ${STAGEDIR}/boot ${INSTALL_PROGRAM} ${WRKSRC}/xen/xen ${STAGEDIR}/boot ${INSTALL_DATA} ${FILESDIR}/xen.4th ${STAGEDIR}/boot .include Index: branches/2017Q4/emulators/xen-kernel/files/xsa236-4.9.patch =================================================================== --- branches/2017Q4/emulators/xen-kernel/files/xsa236-4.9.patch (nonexistent) +++ branches/2017Q4/emulators/xen-kernel/files/xsa236-4.9.patch (revision 452770) @@ -0,0 +1,66 @@ +From: Jan Beulich +Subject: gnttab: fix pin count / page reference race + +Dropping page references before decrementing pin counts is a bad idea +if assumptions are being made that a non-zero pin count implies a valid +page. Fix the order of operations in gnttab_copy_release_buf(), but at +the same time also remove the assertion that was found to trigger: +map_grant_ref() also has the potential of causing a race here, and +changing the order of operations there would likely be quite a bit more +involved. + +This is XSA-236. + +Reported-by: Pawel Wieczorkiewicz +Signed-off-by: Jan Beulich +Reviewed-by: Andrew Cooper + +--- a/xen/common/grant_table.c ++++ b/xen/common/grant_table.c +@@ -2330,9 +2330,20 @@ __acquire_grant_for_copy( + td = page_get_owner_and_reference(*page); + /* + * act->pin being non-zero should guarantee the page to have a +- * non-zero refcount and hence a valid owner. ++ * non-zero refcount and hence a valid owner (matching the one on ++ * record), with one exception: If the owning domain is dying we ++ * had better not make implications from pin count (map_grant_ref() ++ * updates pin counts before obtaining page references, for ++ * example). + */ +- ASSERT(td); ++ if ( td != rd || rd->is_dying ) ++ { ++ if ( td ) ++ put_page(*page); ++ *page = NULL; ++ rc = GNTST_bad_domain; ++ goto unlock_out_clear; ++ } + } + + act->pin += readonly ? GNTPIN_hstr_inc : GNTPIN_hstw_inc; +@@ -2451,6 +2462,11 @@ static void gnttab_copy_release_buf(stru + unmap_domain_page(buf->virt); + buf->virt = NULL; + } ++ if ( buf->have_grant ) ++ { ++ __release_grant_for_copy(buf->domain, buf->ptr.u.ref, buf->read_only); ++ buf->have_grant = 0; ++ } + if ( buf->have_type ) + { + put_page_type(buf->page); +@@ -2461,11 +2477,6 @@ static void gnttab_copy_release_buf(stru + put_page(buf->page); + buf->page = NULL; + } +- if ( buf->have_grant ) +- { +- __release_grant_for_copy(buf->domain, buf->ptr.u.ref, buf->read_only); +- buf->have_grant = 0; +- } + } + + static int gnttab_copy_claim_buf(const struct gnttab_copy *op, Property changes on: branches/2017Q4/emulators/xen-kernel/files/xsa236-4.9.patch ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: branches/2017Q4 =================================================================== --- branches/2017Q4 (revision 452769) +++ branches/2017Q4 (revision 452770) Property changes on: branches/2017Q4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r452769