From owner-svn-ports-all@freebsd.org Tue Oct 24 14:11:23 2017 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9DBF6E4E3DC; Tue, 24 Oct 2017 14:11:23 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 792B0853; Tue, 24 Oct 2017 14:11:23 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9OEBMsJ081687; Tue, 24 Oct 2017 14:11:22 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9OEBMxh081685; Tue, 24 Oct 2017 14:11:22 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201710241411.v9OEBMxh081685@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 24 Oct 2017 14:11:22 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r452769 - in head/emulators/xen-kernel: . files X-SVN-Group: ports-head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head/emulators/xen-kernel: . files X-SVN-Commit-Revision: 452769 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 14:11:23 -0000 Author: royger (src committer) Date: Tue Oct 24 14:11:22 2017 New Revision: 452769 URL: https://svnweb.freebsd.org/changeset/ports/452769 Log: xen: apply XSA-236 Approved by: bapt (implicit) MFH: 2017Q4 Sponsored by: Citrix Systems R&D Added: head/emulators/xen-kernel/files/xsa236-4.9.patch (contents, props changed) Modified: head/emulators/xen-kernel/Makefile Modified: head/emulators/xen-kernel/Makefile ============================================================================== --- head/emulators/xen-kernel/Makefile Tue Oct 24 13:59:12 2017 (r452768) +++ head/emulators/xen-kernel/Makefile Tue Oct 24 14:11:22 2017 (r452769) @@ -2,7 +2,7 @@ PORTNAME= xen PORTVERSION= 4.7.2 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= emulators MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/ PKGNAMESUFFIX= -kernel @@ -80,7 +80,8 @@ EXTRA_PATCHES= ${FILESDIR}/0001-xen-logdirty-prevent-p ${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 Added: head/emulators/xen-kernel/files/xsa236-4.9.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/emulators/xen-kernel/files/xsa236-4.9.patch Tue Oct 24 14:11:22 2017 (r452769) @@ -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,