lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 14 Jun 2019 16:56:32 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Young Xiao <92siuyang@...il.com>
Cc:     Bjorn Helgaas <bhelgaas@...gle.com>,
        Tyrel Datwyler <tyreld@...ux.vnet.ibm.com>,
        linux-pci@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] PCI/hotplug: fix potential null pointer deference

On Fri, Jun 14, 2019 at 3:40 PM Young Xiao <92siuyang@...il.com> wrote:
>
> There is otherwise a risk of a null pointer dereference.

Had you analyze the code?
How come that prevnode can become NULL?

> Signed-off-by: Young Xiao <92siuyang@...il.com>
> ---
>  drivers/pci/hotplug/cpqphp_ctrl.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
> index b7f4e1f..3c8399f 100644
> --- a/drivers/pci/hotplug/cpqphp_ctrl.c
> +++ b/drivers/pci/hotplug/cpqphp_ctrl.c
> @@ -598,10 +598,11 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
>                         *head = node->next;
>                 } else {
>                         prevnode = *head;
> -                       while (prevnode->next != node)
> +                       while (prevnode && prevnode->next != node)
>                                 prevnode = prevnode->next;
>
> -                       prevnode->next = node->next;
> +                       if (prevnode)
> +                               prevnode->next = node->next;
>                 }
>                 node->next = NULL;
>                 break;
> @@ -788,10 +789,11 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
>                         *head = node->next;
>                 } else {
>                         prevnode = *head;
> -                       while (prevnode->next != node)
> +                       while (prevnode && prevnode->next != node)
>                                 prevnode = prevnode->next;
>
> -                       prevnode->next = node->next;
> +                       if (prevnode)
> +                               prevnode->next = node->next;
>                 }
>                 node->next = NULL;
>                 break;
> --
> 2.7.4
>


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ