Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1344981 > unrolled thread

[patch] PCI: hv: potential use after free

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-02-27 11:50 +0100
Last post2016-02-29 20:40 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] PCI: hv: potential use after free Dan Carpenter <dan.carpenter@oracle.com> - 2016-02-27 11:50 +0100
    RE: [patch] PCI: hv: potential use after free Jake Oshins <jakeo@microsoft.com> - 2016-02-29 18:30 +0100
      Re: [patch] PCI: hv: potential use after free Dan Carpenter <dan.carpenter@oracle.com> - 2016-02-29 20:40 +0100

#1344981 — [patch] PCI: hv: potential use after free

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-02-27 11:50 +0100
Subject[patch] PCI: hv: potential use after free
Message-ID<r6KBI-1Bx-5@gated-at.bofh.it>
If we throw away the very last item on the list, then we could end up
with a use after free of "dr".

Fixes: 15ca17645f19 ('PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 9391dee..9b66ffe 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1397,6 +1397,7 @@ static void pci_devices_present_work(struct work_struct *work)
 		/* Throw this away if the list still has stuff in it. */
 		if (!list_empty(&hbus->dr_list)) {
 			kfree(dr);
+			dr = NULL;
 			continue;
 		}
 	}

[toc] | [next] | [standalone]


#1346015

FromJake Oshins <jakeo@microsoft.com>
Date2016-02-29 18:30 +0100
Message-ID<r7zNU-60o-11@gated-at.bofh.it>
In reply to#1344981
> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Saturday, February 27, 2016 2:44 AM
> To: KY Srinivasan <kys@microsoft.com>; Jake Oshins
> <jakeo@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>; Bjorn Helgaas
> <bhelgaas@google.com>; devel@linuxdriverproject.org; linux-
> pci@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [patch] PCI: hv: potential use after free
> 
> If we throw away the very last item on the list, then we could end up
> with a use after free of "dr".
> 
> Fixes: 15ca17645f19 ('PCI: hv: Add paravirtual PCI front-end for Microsoft
> Hyper-V VMs')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 9391dee..9b66ffe 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1397,6 +1397,7 @@ static void pci_devices_present_work(struct
> work_struct *work)
>  		/* Throw this away if the list still has stuff in it. */
>  		if (!list_empty(&hbus->dr_list)) {
>  			kfree(dr);
> +			dr = NULL;
>  			continue;
>  		}
>  	}

Thanks for looking at this.  I do truly appreciate it.  But the code here removes dr from the list and then, before freeing it, checks to see that it was not the last entry in the list.   The list lock is still held and the list is not empty even after removing dr from it.

(I suspect that you're going to tell me that I'm missing something here.  Please do.  I'll appreciate it even more.)

Thanks,
Jake

[toc] | [prev] | [next] | [standalone]


#1346123

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-02-29 20:40 +0100
Message-ID<r7BPI-7hF-7@gated-at.bofh.it>
In reply to#1346015
You're right.  My bad.

regards,
dan carpenter

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web