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] [day] [month] [year] [list]
Date:   Thu, 19 Sep 2019 20:38:36 +0000
From:   "Kuehling, Felix" <Felix.Kuehling@....com>
To:     Allen Pais <allen.pais@...cle.com>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>
CC:     "airlied@...ux.ie" <airlied@...ux.ie>,
        "daniel@...ll.ch" <daniel@...ll.ch>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>
Subject: Re: [PATCH] drm/amdkfd: fix a potential NULL pointer dereference

On 2019-09-18 12:30 p.m., Allen Pais wrote:
> alloc_workqueue is not checked for errors and as a result,
> a potential NULL dereference could occur.
>
> Signed-off-by: Allen Pais <allen.pais@...cle.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index c56ac47..caa82a8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -62,6 +62,11 @@ int kfd_interrupt_init(struct kfd_dev *kfd)
>   	}
>   
>   	kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
> +	if (unlikely(!kfd->ih_wq)) {
> +		fifo_free(&kfd->ih_fifo);

This does not compile. I think this should be kfifo_free.

> +		dev_err(kfd_chardev(), "Failed to allocate KFD IH workqueue\n");
> +		return kfd->ih_wq;

This throws a compiler warning "return makes integer from pointer 
without a cast". What's worse, kfd->ih_wq is NULL here and 
kfd_interrupt_init returns 0 to mean success, so returning a NULL 
pointer is definitely not what you want here. This function should 
return a negative error code on failure. I propose -ENOMEM.

I'm going to apply your patch with those fixes.

Regards,
   Felix


> +	}
>   	spin_lock_init(&kfd->interrupt_lock);
>   
>   	INIT_WORK(&kfd->interrupt_work, interrupt_wq);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ