Re: [BUG] usbip: vhci: Sleeping function called from invalid context in vhci_urb_enqueue on PREEMPT_RT

Yunseong Kim
2025-08-16T01:47:15Z

P.S.

Just to clarify,

On 8/16/25 10:29 AM, Yunseong Kim wrote:
> While testing a PREEMPT_RT enabled kernel (based on v6.17.0-rc1),
> I encountered a "BUG: sleeping function called from invalid context"
> error originating from the USB/IP VHCI driver.
>
> On PREEMPT_RT configurations, standard spin_lock() calls are replaced by
> rt_spin_lock(). Since rt_spin_lock() may sleep when contended, it must not
> be called from an atomic context (e.g., with interrupts disabled).
>
> The issue occurs within the vhci_urb_enqueue function This function
> explicitly disables local interrupts using local_irq_disable() immediately
> before calling usb_hcd_giveback_urb(), adhering to HCD requirements.
>
> This error reported after this work:
> Link: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-linus&id=9528d32873b38281ae105f2f5799e79ae9d086c2

To be clear and avoid any misunderstanding, reporting was done after
this work "kcov, usb: Don't disable interrupts in kcov_remote_start_usb_softirq()"
because the fuzzing could proceed smoothly on PREEMPT_RT following this work,
which allowed the issue to be discovered. It does not mean that this step
introduced the error at all.