From: "Jan Beulich" Subject: Re: [Patch] x86/mm: Prevent leaking domain mappings in paging_log_dirty_op() Date: Tue, 10 Dec 2013 14:45:58 +0000 Message-ID: <52A73736020000780010BE37@nat28.tlf.novell.com> References: <1386683636-5836-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VqOZW-0003o7-SJ for xen-devel@lists.xenproject.org; Tue, 10 Dec 2013 14:46:02 +0000 In-Reply-To: <1386683636-5836-1-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 10.12.13 at 14:53, Andrew Cooper wrote: > Coverity ID: 1135374 1135375 1135376 1135377 > > If {copy_to,clear}_guest_offset() fails, we would leak the domain mappings > for > l4 thru l1. > > Fixing this requires having conditional unmaps on the faulting path, which > in > turn requires explicitly initialising the pointers to NULL because of the > early ENOMEM exit. > > Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich with a minor comment: > @@ -432,6 +432,15 @@ int paging_log_dirty_op(struct domain *d, struct xen_domctl_shadow_op *sc) > return rv; > > out: > + if ( l1 ) > + unmap_domain_page(l1); > + if ( l2 ) > + unmap_domain_page(l2); > + if ( l3 ) > + unmap_domain_page(l3); > + if ( l4 ) > + unmap_domain_page(l4); > + > paging_unlock(d); > domain_unpause(d); > return rv; While on an error path, it would nevertheless seem better to do the unmaps after the unlock/unpause. Jan