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]
Message-ID: <b452f7a7-99fa-e023-9120-639b4110de73@xs4all.nl>
Date:   Thu, 17 Feb 2022 13:05:42 +0100
From:   Hans Verkuil <hverkuil@...all.nl>
To:     Dongliang Mu <dzm91@...t.edu.cn>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Dongliang Mu <mudongliangabcd@...il.com>
Cc:     syzkaller <syzkaller@...glegroups.com>,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] media: hdpvr: call flush_work only if initialized

On 17/02/2022 05:39, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@...il.com>
> 
> flush_work will throw one WARN if worker->func is NULL. So we should always
> initialize one worker before calling flush_work. When hdpvr_probe does not
> initialize its worker, the hdpvr_disconnect will encounter one WARN. The
> stack trace is in the following:
> 
>  hdpvr_disconnect+0xb8/0xf2 drivers/media/usb/hdpvr/hdpvr-core.c:425
>  usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458
>  __device_release_driver drivers/base/dd.c:1206 [inline]
>  device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1237
>  bus_remove_device+0x108/0x160 drivers/base/bus.c:529
>  device_del+0x1fe/0x510 drivers/base/core.c:3592
>  usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419
>  usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2228
> 
> Fix this by adding a sanity check of the worker before flush_work.
> 
> Reported-by: syzkaller <syzkaller@...glegroups.com>
> Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
> ---
>  drivers/media/usb/hdpvr/hdpvr-core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
> index 52e05a69c46e..d102b459d45d 100644
> --- a/drivers/media/usb/hdpvr/hdpvr-core.c
> +++ b/drivers/media/usb/hdpvr/hdpvr-core.c
> @@ -422,7 +422,8 @@ static void hdpvr_disconnect(struct usb_interface *interface)
>  	mutex_unlock(&dev->io_mutex);
>  	v4l2_device_disconnect(&dev->v4l2_dev);
>  	msleep(100);
> -	flush_work(&dev->worker);
> +	if (dev->worker.func)
> +		flush_work(&dev->worker);

I don't think this is the right fix. Instead, move the INIT_WORK line from
hdpvr_start_streaming() to hdpvr_register_videodev(). That should initialize
the worker struct from the start instead of only when you start streaming,
as is the case today.

Can you try that?

Regards,

	Hans

>  	mutex_lock(&dev->io_mutex);
>  	hdpvr_cancel_queue(dev);
>  	mutex_unlock(&dev->io_mutex);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ