All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
Cc: Keir Fraser <keir@xen.org>, Jan Beulich <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v3 1/2] amd/passthrough: Do not leak domain mappings from do_invalidate_dte()
Date: Mon, 9 Dec 2013 18:34:56 +0000	[thread overview]
Message-ID: <52A60D50.4060100@citrix.com> (raw)
In-Reply-To: <52A60CED.7090108@amd.com>

On 09/12/13 18:33, Suravee Suthikulanit wrote:
> On 12/4/2013 11:59 AM, Andrew Cooper wrote:
>> Coverity ID: 1135379
>>
>> As the code stands, the domain mapping will be leaked on each error
>> path.
>>
>> The mapping can be for a much shorter period of time, and all the
>> relevent
>> information can be pulled out at once.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> CC: Keir Fraser <keir@xen.org>
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>>
>> ---
>>
>> Changes in v3:
>>   * Dont break the pointer arithmatic on gdte
>> ---
>>   xen/drivers/passthrough/amd/iommu_guest.c |    9 ++++-----
>>   1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/xen/drivers/passthrough/amd/iommu_guest.c
>> b/xen/drivers/passthrough/amd/iommu_guest.c
>> index 952600a..c1fa0ff 100644
>> --- a/xen/drivers/passthrough/amd/iommu_guest.c
>> +++ b/xen/drivers/passthrough/amd/iommu_guest.c
>> @@ -430,6 +430,10 @@ static int do_invalidate_dte(struct domain *d,
>> cmd_entry_t *cmd)
>>         gdom_id  = get_domid_from_dte(gdte);
>>       gcr3_gfn = get_guest_cr3_from_dte(gdte);
>> +    glx      = get_glx_from_dte(gdte);
>> +    gv       = get_gv_from_dte(gdte);
>> +
>> +    unmap_domain_page(gdte);
> Shouldn't this be "unmap_domain_page (dte_base)" instead?

Probably should be.

>
>>         /* Do not update host dte before gcr3 has been set */
>>       if ( gcr3_gfn == 0 )
>> @@ -449,11 +453,6 @@ static int do_invalidate_dte(struct domain *d,
>> cmd_entry_t *cmd)
>>           return -ENODEV;
>>       }
>>   -    glx = get_glx_from_dte(gdte);
>> -    gv = get_gv_from_dte(gdte);
>> -
>> -    unmap_domain_page(dte_base);
>> -
>>       /* Setup host device entry */
>>       hdom_id = host_domid(d, gdom_id);
>>       req_id = get_dma_requestor_id(iommu->seg, mbdf);
> Also, the comment saying "/* Read guest dte information */ " should
> probably be moved as well.
>
> Suravee
>

Sure - v4 on its way.

~Andrew

  reply	other threads:[~2013-12-09 18:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 15:09 [PATCH 0/2] Coverity fixes for map_domain_page() mismatches Andrew Cooper
2013-12-04 15:09 ` [PATCH 1/2] amd/passthrough: Do not leak domain mappings from do_invalidate_dte() Andrew Cooper
2013-12-04 15:22   ` Jan Beulich
2013-12-04 15:30     ` Andrew Cooper
2013-12-04 16:44     ` [PATCH v2 " Andrew Cooper
2013-12-04 16:49       ` Jan Beulich
2013-12-04 17:59         ` [PATCH v3 " Andrew Cooper
2013-12-06  8:37           ` Jan Beulich
2013-12-09 10:08           ` Jan Beulich
2013-12-09 18:33           ` Suravee Suthikulanit
2013-12-09 18:34             ` Andrew Cooper [this message]
2013-12-09 18:41             ` [PATCH v4 " Andrew Cooper
2013-12-09 20:02               ` Suravee Suthikulpanit
2013-12-04 15:09 ` [PATCH 2/2] xen/page_alloc: Defer the domain mapping in scrub_one_page() Andrew Cooper
2013-12-04 15:23   ` Jan Beulich
2013-12-09 10:09   ` Jan Beulich
2013-12-09 11:02     ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A60D50.4060100@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.