mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Yuanzhe Liu <25031212351@stu.xidian.edu.cn>
Cc: mchehab@kernel.org, oneukum@suse.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/1] media: rc: igorplugusb: quiesce callbacks before unregister
Date: Thu, 24 Sep 2026 09:25:16 +0100	[thread overview]
Message-ID: <arTebGLt_KKQiiud@extorris.mess.org> (raw)
In-Reply-To: <20260924025351.122-2-25031212351@stu.xidian.edu.cn>

On Thu, Sep 24, 2026 at 10:53:51AM +0800, Yuanzhe Liu wrote:
> igorplugusb_disconnect() unregisters the rc device before poisoning its
> URB. rc_unregister_device() stops the raw-IR kthread, but a completion
> callback that is already running can still call ir_raw_event_handle().
> This makes wake_up_process() dereference the kthread's freed task_struct
> and triggers a KASAN use-after-free in try_to_wake_up().

This is problem with the framework rather than the driver. The
media-committers tree already contains a fix for this issue:

https://gitlab.freedesktop.org/linux-media/media-committers/-/commit/3ae19773168104fa57d2a2ec57731e89df54175f

> Poison the URB and delete the timer before unregistering the rc device.
> Poisoning drains any active callback and prevents resubmission, while
> deleting the timer stops the other URB producer. No callback can then
> reach rc-core after its raw-IR kthread has been stopped.

Stopping all the urbs before calling rc_unregister_device() isn't really an
option for all drivers. Users can still do various ioctl/write on the lirc
chardev which could bring various URBs back into flight. For receive-only IR
devices like igorplugusb this might not be an problem.

Thanks,

Sean

> 
> Fixes: b1c97193c643 ("[media] rc: port IgorPlug-USB to rc-core")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuanzhe Liu <25031212351@stu.xidian.edu.cn>
> ---
>  drivers/media/rc/igorplugusb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c
> index b5117ee..42e05b9 100644
> --- a/drivers/media/rc/igorplugusb.c
> +++ b/drivers/media/rc/igorplugusb.c
> @@ -241,9 +241,9 @@ static void igorplugusb_disconnect(struct usb_interface *intf)
>  {
>  	struct igorplugusb *ir = usb_get_intfdata(intf);
>  
> -	rc_unregister_device(ir->rc);
>  	usb_poison_urb(ir->urb);
>  	timer_delete_sync(&ir->timer);
> +	rc_unregister_device(ir->rc);
>  	usb_set_intfdata(intf, NULL);
>  	usb_unpoison_urb(ir->urb);
>  	usb_free_urb(ir->urb);
> -- 
> 2.45.1.windows.1
> 

      reply	other threads:[~2026-09-24  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  2:53 [PATCH 0/1] media: rc: fix igorplugusb disconnect UAF Yuanzhe Liu
2026-09-24  2:53 ` [PATCH 1/1] media: rc: igorplugusb: quiesce callbacks before unregister Yuanzhe Liu
2026-09-24  8:25   ` Sean Young [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arTebGLt_KKQiiud@extorris.mess.org \
    --to=sean@mess.org \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=oneukum@suse.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®