Re: [PATCH] kthread: Unpark only parked kthreads (was Re: [syzbot] [wireguard?] WARNING in kthread_unpark (2))

From: Frederic Weisbecker
Date: Fri Sep 13 2024 - 08:31:59 EST


Le Fri, Sep 13, 2024 at 08:11:09PM +0800, Hillf Danton a écrit :
> Test Frederic's idea.
>
> #syz test upstream master

Thanks!

>
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -623,6 +623,8 @@ void kthread_unpark(struct task_struct *
> {
> struct kthread *kthread = to_kthread(k);
>
> + if (!test_bit(KTHREAD_SHOULD_PARK, &kthread->flags))
> + return;
> /*
> * Newly created kthread was parked when the CPU was offline.
> * The binding was lost and we need to set it again.

But are the following bits deliberate?

> --- l/drivers/input/misc/yealink.c
> +++ y/drivers/input/misc/yealink.c
> @@ -438,7 +438,7 @@ static void urb_irq_callback(struct urb
>
> yealink_do_idle_tasks(yld);
>
> - if (!yld->shutdown) {
> + if (!yld->shutdown && status != -EPROTO) {
> ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
> if (ret && ret != -EPERM)
> dev_err(&yld->intf->dev,
> @@ -460,13 +460,13 @@ static void urb_ctl_callback(struct urb
> case CMD_KEYPRESS:
> case CMD_SCANCODE:
> /* ask for a response */
> - if (!yld->shutdown)
> + if (!yld->shutdown && status != -EPROTO)
> ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC);
> break;
> default:
> /* send new command */
> yealink_do_idle_tasks(yld);
> - if (!yld->shutdown)
> + if (!yld->shutdown && status != -EPROTO)
> ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
> break;
> }
> --
>