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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 2 Apr 2021 17:06:25 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Yufen Yu <yuyufen@...wei.com>
Cc:     linux-kernel@...r.kernel.org, rafael@...nel.org, axboe@...nel.dk,
        hch@....de, linux-block@...r.kernel.org
Subject: Re: [PATCH] drivers core: don't do anything in device_del() when
 device_add() fail

On Thu, Apr 01, 2021 at 09:01:38AM -0400, Yufen Yu wrote:
> Recently, our syzbot test reported NULL pointer dereference in
> device_del() by injecting memory allocation fail in device_add().

Don't do that :)

> For now, callers of device_add(), such as add_disk(), may ignore
> device_add()'s fail and go on working.

Please fix up those users, if device_add() fails there is no need to
call device_del().

> In unregister path, it will
> call device_del() from del_gendisk(). That can cause various NULL
> pointer dereference, including dev->p is NULL in kill_device(),
> 'name' is NULL in sysfs_remove_link(), kobj->sd is 'NULL' when call
> dpm_sysfs_remove(), and so on.
> 
> To avoid these kernel panic, we call device_del() only when device_add()
> is success.

As Rafael said, that's not what you are doing here, so even if I wanted
to take this patch, I can't.

> 
> Signed-off-by: Yufen Yu <yuyufen@...wei.com>
> ---
>  drivers/base/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index f29839382f81..a10ec5dbc577 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3380,6 +3380,9 @@ void device_del(struct device *dev)
>  	struct class_interface *class_intf;
>  	unsigned int noio_flag;
>  
> +	if (!dev->p)
> +		return;

Also, this isn't a good test as it's not obvious what you are trying to
check for here.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ