Re: [PATCH] xen/pciback: Prevent NULL pointer dereference in quirks_show
From: Boris Ostrovsky
Date: Fri Dec 06 2019 - 10:11:56 EST
On 12/6/19 8:48 AM, Stefan Nuernberger wrote:
> From: Uwe Dannowski <uwed@xxxxxxxxx>
>
> Reading /sys/bus/pci/drivers/pciback/quirks while unbinding can result
> in dereferencing a NULL pointer. Instead, skip printing information
> about the dangling quirk.
>
> Reported-by: Conny Seidel <consei@xxxxxxxxx>
> Signed-off-by: Uwe Dannowski <uwed@xxxxxxxxx>
> Signed-off-by: Stefan Nuernberger <snu@xxxxxxxxxx>
>
> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> drivers/xen/xen-pciback/pci_stub.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
> index 097410a7cdb7..da725e474294 100644
> --- a/drivers/xen/xen-pciback/pci_stub.c
> +++ b/drivers/xen/xen-pciback/pci_stub.c
> @@ -1346,6 +1346,8 @@ static ssize_t quirks_show(struct device_driver *drv, char *buf)
> quirk->devid.subdevice);
>
> dev_data = pci_get_drvdata(quirk->pdev);
> + if (!dev_data)
> + continue;
>
> list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
Couldn't you have the same race here?
-boris
> field = cfg_entry->field;