Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: Lixu Zhang <lixu.zhang@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
	Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH] usb: ljca: fix NULL pointer dereference on events for callback-less clients
Date: Fri, 20 Nov 2026 17:06:20 +0100	[thread overview]
Message-ID: <2026112045-napping-suitcase-26b0@gregkh> (raw)
In-Reply-To: <20261120150143.2591-1-25031212351@stu.xidian.edu.cn>

On Fri, Nov 20, 2026 at 11:01:43PM +0800, YuanZhe Liu wrote:
> ljca_handle_event() dispatches an incoming event message to the first
> client whose type matches the message type and calls that client's event
> callback without checking that a callback is registered.  Only the GPIO
> client calls ljca_register_event_cb(); the I2C and SPI clients never do,
> so their event_cb stays NULL for as long as the adapter is bound, while
> they are present in adap->client_list.
> 
> A device that sends a message without LJCA_ACK_FLAG and with the type of
> such a client therefore makes the driver call a NULL function pointer
> from the URB completion handler:

What device does that?  How?

> 
>   BUG: kernel NULL pointer dereference, address: 0000000000000000
>   #PF: supervisor instruction fetch in kernel mode
>   RIP: 0010:0x0
>   Call Trace:
>    ljca_handle_event drivers/usb/misc/usb-ljca.c:217 [inline]
>    ljca_recv+0x651/0x850 drivers/usb/misc/usb-ljca.c:295
>    __usb_hcd_giveback_urb+0x238/0x550 drivers/usb/core/hcd.c:1657
> 
> Check event_cb under client->event_cb_lock and skip the call when no
> callback is registered.  The same lock is taken by
> ljca_register_event_cb() and ljca_unregister_event_cb(), so the check
> cannot be invalidated before the call.

How was this tested, shouldn't the driver be fixed up not to do that
instead of this workaround?

thanks,

greg k-h

  reply	other threads:[~2026-11-20 16:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 15:01 [PATCH] usb: ljca: fix NULL pointer dereference on events for callback-less clients YuanZhe Liu
2026-11-20 16:06 ` Greg Kroah-Hartman [this message]
2026-11-20 16:35   ` YuanZhe Liu

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=2026112045-napping-suitcase-26b0@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=byu@xidian.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lixu.zhang@intel.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=wencheng@xidian.edu.cn \
    /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