mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
@ 2026-08-21 11:48 Deepanshu Kartikey
  2026-09-12  1:11 ` Deepanshu Kartikey
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Deepanshu Kartikey @ 2026-08-21 11:48 UTC (permalink / raw)
  To: gregkh
  Cc: kees, pavel.hofman, linux-usb, linux-kernel, Deepanshu Kartikey,
	syzbot+e1d0e66badecc32d45eb

u_audio_get_playback_srate() unconditionally locks and reads
uac->p_prm.lock/srate, but g_audio_setup() only initializes
p_prm.lock when p_chmask is set. On a UAC2 instance configured
without a playback direction, this results in acquiring a
never spin_lock_init()'d lock when a GET_CUR sample rate
request targets playback, triggering a lockdep "trying to
register non-static key" warning.

Reject the request with -EOPNOTSUPP when p_chmask is not set,
before touching prm->lock.

Fixes: eb3a1ce6f5ed ("usb: gadget: u_audio: Add capture/playback srate getter")
Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 drivers/usb/gadget/function/u_audio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index e53f2927b539..ff811ea1e25a 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
 	struct uac_rtd_params *prm;
 	unsigned long flags;
 
+	if (!audio_dev->params.p_chmask)
+		return -EOPNOTSUPP;
+
 	prm = &uac->p_prm;
 	spin_lock_irqsave(&prm->lock, flags);
 	*val = prm->srate;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
  2026-08-21 11:48 [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction Deepanshu Kartikey
@ 2026-09-12  1:11 ` Deepanshu Kartikey
  2026-09-23  3:31 ` Deepanshu Kartikey
  2026-09-29 13:23 ` Greg KH
  2 siblings, 0 replies; 7+ messages in thread
From: Deepanshu Kartikey @ 2026-09-12  1:11 UTC (permalink / raw)
  To: gregkh
  Cc: kees, pavel.hofman, linux-usb, linux-kernel, syzbot+e1d0e66badecc32d45eb

On Fri, Aug 21, 2026 at 5:19 PM Deepanshu Kartikey
<kartikey406@gmail.com> wrote:
>
> u_audio_get_playback_srate() unconditionally locks and reads
> uac->p_prm.lock/srate, but g_audio_setup() only initializes
> p_prm.lock when p_chmask is set. On a UAC2 instance configured
> without a playback direction, this results in acquiring a
> never spin_lock_init()'d lock when a GET_CUR sample rate
> request targets playback, triggering a lockdep "trying to
> register non-static key" warning.
>
> Reject the request with -EOPNOTSUPP when p_chmask is not set,
> before touching prm->lock.
>
> Fixes: eb3a1ce6f5ed ("usb: gadget: u_audio: Add capture/playback srate getter")
> Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/usb/gadget/function/u_audio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> index e53f2927b539..ff811ea1e25a 100644
> --- a/drivers/usb/gadget/function/u_audio.c
> +++ b/drivers/usb/gadget/function/u_audio.c
> @@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
>         struct uac_rtd_params *prm;
>         unsigned long flags;
>
> +       if (!audio_dev->params.p_chmask)
> +               return -EOPNOTSUPP;
> +
>         prm = &uac->p_prm;
>         spin_lock_irqsave(&prm->lock, flags);
>         *val = prm->srate;
> --
> 2.43.0
>

Gentle Reminder. Please let me know the status of this patch

Thanks

Deepanshu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
  2026-08-21 11:48 [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction Deepanshu Kartikey
  2026-09-12  1:11 ` Deepanshu Kartikey
@ 2026-09-23  3:31 ` Deepanshu Kartikey
  2026-09-29 13:23   ` Greg KH
  2026-09-29 13:23 ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Deepanshu Kartikey @ 2026-09-23  3:31 UTC (permalink / raw)
  To: gregkh
  Cc: kees, pavel.hofman, linux-usb, linux-kernel, syzbot+e1d0e66badecc32d45eb

On Fri, Aug 21, 2026 at 5:19 PM Deepanshu Kartikey
<kartikey406@gmail.com> wrote:
>
> u_audio_get_playback_srate() unconditionally locks and reads
> uac->p_prm.lock/srate, but g_audio_setup() only initializes
> p_prm.lock when p_chmask is set. On a UAC2 instance configured
> without a playback direction, this results in acquiring a
> never spin_lock_init()'d lock when a GET_CUR sample rate
> request targets playback, triggering a lockdep "trying to
> register non-static key" warning.
>
> Reject the request with -EOPNOTSUPP when p_chmask is not set,
> before touching prm->lock.
>
> Fixes: eb3a1ce6f5ed ("usb: gadget: u_audio: Add capture/playback srate getter")
> Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/usb/gadget/function/u_audio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> index e53f2927b539..ff811ea1e25a 100644
> --- a/drivers/usb/gadget/function/u_audio.c
> +++ b/drivers/usb/gadget/function/u_audio.c
> @@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
>         struct uac_rtd_params *prm;
>         unsigned long flags;
>
> +       if (!audio_dev->params.p_chmask)
> +               return -EOPNOTSUPP;
> +
>         prm = &uac->p_prm;
>         spin_lock_irqsave(&prm->lock, flags);
>         *val = prm->srate;
> --
> 2.43.0
>

Gentle Reminder. Please let me know the status of this patch.

Thanks

Deepanshu

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
  2026-09-23  3:31 ` Deepanshu Kartikey
@ 2026-09-29 13:23   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2026-09-29 13:23 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: kees, pavel.hofman, linux-usb, linux-kernel, syzbot+e1d0e66badecc32d45eb

On Wed, Sep 23, 2026 at 09:01:22AM +0530, Deepanshu Kartikey wrote:
> On Fri, Aug 21, 2026 at 5:19 PM Deepanshu Kartikey
> <kartikey406@gmail.com> wrote:
> >
> > u_audio_get_playback_srate() unconditionally locks and reads
> > uac->p_prm.lock/srate, but g_audio_setup() only initializes
> > p_prm.lock when p_chmask is set. On a UAC2 instance configured
> > without a playback direction, this results in acquiring a
> > never spin_lock_init()'d lock when a GET_CUR sample rate
> > request targets playback, triggering a lockdep "trying to
> > register non-static key" warning.
> >
> > Reject the request with -EOPNOTSUPP when p_chmask is not set,
> > before touching prm->lock.
> >
> > Fixes: eb3a1ce6f5ed ("usb: gadget: u_audio: Add capture/playback srate getter")
> > Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> > Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> > Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> > ---
> >  drivers/usb/gadget/function/u_audio.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> > index e53f2927b539..ff811ea1e25a 100644
> > --- a/drivers/usb/gadget/function/u_audio.c
> > +++ b/drivers/usb/gadget/function/u_audio.c
> > @@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
> >         struct uac_rtd_params *prm;
> >         unsigned long flags;
> >
> > +       if (!audio_dev->params.p_chmask)
> > +               return -EOPNOTSUPP;
> > +
> >         prm = &uac->p_prm;
> >         spin_lock_irqsave(&prm->lock, flags);
> >         *val = prm->srate;
> > --
> > 2.43.0
> >
> 
> Gentle Reminder. Please let me know the status of this patch.

If you wish to see patches reviewed quicker, please help out and review
other submissions which will cause your patch to move to the top.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
  2026-08-21 11:48 [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction Deepanshu Kartikey
  2026-09-12  1:11 ` Deepanshu Kartikey
  2026-09-23  3:31 ` Deepanshu Kartikey
@ 2026-09-29 13:23 ` Greg KH
  2 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2026-09-29 13:23 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: kees, pavel.hofman, linux-usb, linux-kernel, syzbot+e1d0e66badecc32d45eb

On Fri, Aug 21, 2026 at 05:18:54PM +0530, Deepanshu Kartikey wrote:
> u_audio_get_playback_srate() unconditionally locks and reads
> uac->p_prm.lock/srate, but g_audio_setup() only initializes
> p_prm.lock when p_chmask is set. On a UAC2 instance configured
> without a playback direction, this results in acquiring a
> never spin_lock_init()'d lock when a GET_CUR sample rate
> request targets playback, triggering a lockdep "trying to
> register non-static key" warning.
> 
> Reject the request with -EOPNOTSUPP when p_chmask is not set,
> before touching prm->lock.
> 
> Fixes: eb3a1ce6f5ed ("usb: gadget: u_audio: Add capture/playback srate getter")
> Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---

How was this tested?

Did you forget a Assisted-by: tag?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
       [not found] <20260821114427.11896-1-kartikey406@gmail.com>
@ 2026-08-21 11:44 ` syzbot
  0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2026-08-21 11:44 UTC (permalink / raw)
  To: kartikey406; +Cc: kartikey406, linux-kernel, syzkaller-bugs

> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

This crash does not have a reproducer. I cannot test it.

>
> u_audio_get_playback_srate() unconditionally locks and reads
> uac->p_prm.lock/srate, but g_audio_setup() only initializes
> p_prm.lock when p_chmask is set. On a UAC2 instance configured
> without a playback direction, this results in acquiring a
> never spin_lock_init()'d lock when a GET_CUR sample rate
> request targets playback, triggering a lockdep "trying to
> register non-static key" warning.
>
> Reject the request with -EOPNOTSUPP when p_chmask is not set,
> before touching prm->lock.
>
> Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/usb/gadget/function/u_audio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> index e53f2927b539..ff811ea1e25a 100644
> --- a/drivers/usb/gadget/function/u_audio.c
> +++ b/drivers/usb/gadget/function/u_audio.c
> @@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
>  	struct uac_rtd_params *prm;
>  	unsigned long flags;
>  
> +	if (!audio_dev->params.p_chmask)
> +		return -EOPNOTSUPP;
> +
>  	prm = &uac->p_prm;
>  	spin_lock_irqsave(&prm->lock, flags);
>  	*val = prm->srate;
> -- 
> 2.43.0
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction
       [not found] <20260821114238.11840-1-kartikey406@gmail.com>
@ 2026-08-21 11:42 ` syzbot
  0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2026-08-21 11:42 UTC (permalink / raw)
  To: kartikey406; +Cc: kartikey406, linux-kernel, syzkaller-bugs

> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

This crash does not have a reproducer. I cannot test it.

>
>
> u_audio_get_playback_srate() unconditionally locks and reads
> uac->p_prm.lock/srate, but g_audio_setup() only initializes
> p_prm.lock when p_chmask is set. On a UAC2 instance configured
> without a playback direction, this results in acquiring a
> never spin_lock_init()'d lock when a GET_CUR sample rate
> request targets playback, triggering a lockdep "trying to
> register non-static key" warning.
>
> Reject the request with -EOPNOTSUPP when p_chmask is not set,
> before touching prm->lock.
>
> Reported-by: syzbot+e1d0e66badecc32d45eb@syzkaller.appspotmail.com
> Closes: http://syzkaller.appspot.com/bug?extid=e1d0e66badecc32d45eb
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/usb/gadget/function/u_audio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> index e53f2927b539..ff811ea1e25a 100644
> --- a/drivers/usb/gadget/function/u_audio.c
> +++ b/drivers/usb/gadget/function/u_audio.c
> @@ -575,6 +575,9 @@ int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val)
>  	struct uac_rtd_params *prm;
>  	unsigned long flags;
>  
> +	if (!audio_dev->params.p_chmask)
> +		return -EOPNOTSUPP;
> +
>  	prm = &uac->p_prm;
>  	spin_lock_irqsave(&prm->lock, flags);
>  	*val = prm->srate;
> -- 
> 2.43.0
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-29 13:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 11:48 [PATCH] usb: gadget: u_audio: reject srate request for unconfigured direction Deepanshu Kartikey
2026-09-12  1:11 ` Deepanshu Kartikey
2026-09-23  3:31 ` Deepanshu Kartikey
2026-09-29 13:23   ` Greg KH
2026-09-29 13:23 ` Greg KH
     [not found] <20260821114427.11896-1-kartikey406@gmail.com>
2026-08-21 11:44 ` syzbot
     [not found] <20260821114238.11840-1-kartikey406@gmail.com>
2026-08-21 11:42 ` syzbot

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®