[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH 3/8] VT-d: plug memory leaks in iommu_alloc()


  • To: "Beulich, Jan" <JBeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Wed, 20 Apr 2022 06:23:01 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BIWWfM9iZH0+bH/FAioA3hD07UHmH0hPVS3+Dk9IaFc=; b=WUA8Vbi9aTIGBqb9LLtzNNSbkayauJxceu9r1jV10fz09YX7KQaRUMGv8omFaWZuPaIzgB8nqiolz3V/fMEkdrbuhGNEPYts9X60Ezz4RhjQGwc/JtqDd3rmkSjX7X+birv5MBGbU2f/tjjKxOrw0ZB9cqp1K+JHSkeH62mf8u6sjWw83NtWoBi7uxmxrvgurrsUMFTFUw4UWXbZkwD/4fDe6y068C1Y1xDgOSj/BFWUzVM+PHEPMKPEVEbZ/roAqk+5fY8lp16pdDuHv89Xj3f9wDLrgrxqc5cdhTwng2Yv+HeVrCoumzdNCm51Vpv8I5C+puhVJtPM2CWD1WkwfQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QMJfUEhVSzm4yx1NkGLLGHqv3rxUvc/X4X1rEg7DSlBJtJxbCaHshMjmGzEZMHWRX0Sg8zL/sxPqohkFFR60UxUJ+TAhaqDxmd/ynWWBu4+rBZ9avfdn92o219Pvy84X3ADvgurArkKdTzGl1EbUf2r1Q/J4IlXmVNyEs/ftAtmEr3yzvhCBzfDqhh4Wq9b6C2c0WTHAg5nOtj6X4B+isHoj7gUOGijtNF8VixhFtBoIDw4o6vSEyeFtzZuKZFnkQECKfeiGCEQgqjBuCsl/xVarMC5Wafc4gfj/R2jc458e0+fAOoeV6xmPq1o32EjSbuQRftbPZQEZ1eKYXPMPaQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Pau Monné, Roger <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 20 Apr 2022 06:23:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYTYexZ6cM0C9e8k+mDwbf10797Kz4YUeQ
  • Thread-topic: [PATCH 3/8] VT-d: plug memory leaks in iommu_alloc()

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Monday, April 11, 2022 5:37 PM
> 
> While 97af062b89d5 ("IOMMU/x86: maintain a per-device pseudo domain
> ID")
> took care of not making things worse, plugging pre-existing leaks wasn't
> the purpose of that change; they're not security relevant after all.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -1238,8 +1238,9 @@ int __init iommu_alloc(struct acpi_drhd_
>      drhd->iommu = iommu;
> 
>      iommu->reg = ioremap(drhd->address, PAGE_SIZE);
> +    rc = -ENOMEM;
>      if ( !iommu->reg )
> -        return -ENOMEM;
> +        goto free;
>      iommu->index = nr_iommus++;
> 
>      iommu->cap = dmar_readq(iommu->reg, DMAR_CAP_REG);
> @@ -1260,8 +1261,9 @@ int __init iommu_alloc(struct acpi_drhd_
>          printk(VTDPREFIX "cap = %"PRIx64" ecap = %"PRIx64"\n",
>                 iommu->cap, iommu->ecap);
>      }
> +    rc = -ENODEV;
>      if ( !(iommu->cap + 1) || !(iommu->ecap + 1) )
> -        return -ENODEV;
> +        goto free;
> 
>      quirk_iommu_caps(iommu);
> 
> @@ -1272,7 +1274,8 @@ int __init iommu_alloc(struct acpi_drhd_
>      {
>          printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported\n");
>          print_iommu_regs(drhd);
> -        return -ENODEV;
> +        rc = -ENODEV;
> +        goto free;
>      }
> 
>      /* Calculate number of pagetable levels: 3 or 4. */
> @@ -1283,7 +1286,8 @@ int __init iommu_alloc(struct acpi_drhd_
>      {
>          printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported sagaw %x\n",
> sagaw);
>          print_iommu_regs(drhd);
> -        return -ENODEV;
> +        rc = -ENODEV;
> +        goto free;
>      }
>      iommu->nr_pt_levels = agaw_to_level(agaw);
> 
> @@ -1298,8 +1302,9 @@ int __init iommu_alloc(struct acpi_drhd_
>          iommu->domid_bitmap = xzalloc_array(unsigned long,
>                                              BITS_TO_LONGS(nr_dom));
>          iommu->domid_map = xzalloc_array(domid_t, nr_dom);
> +        rc = -ENOMEM;
>          if ( !iommu->domid_bitmap || !iommu->domid_map )
> -            return -ENOMEM;
> +            goto free;
> 
>          /*
>           * If Caching mode is set, then invalid translations are tagged


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.