From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: bolewara@gmail.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+38bab69d2760cc99cfbe@syzkaller.appspotmail.com,
syzbot+a4f65284f1451010b0a8@syzkaller.appspotmail.com
Subject: Re: [PATCH 1/2] usb: gadget: f_uac2: fix invalid-free in srate configfs store
Date: Fri, 20 Nov 2026 10:51:08 +0100 [thread overview]
Message-ID: <2026112000-shed-motor-c5f0@gregkh> (raw)
In-Reply-To: <20260804-f-uac-srate-invalid-free-v1-1-2c980378cdf5@gmail.com>
On Tue, Aug 04, 2026 at 11:13:23PM +0530, Anuj Bolewar via B4 Relay wrote:
> From: Anuj Bolewar <bolewara@gmail.com>
>
> The store path for the p_srate/c_srate attributes calls kfree() on
> split_page after it has been advanced by strsep(). When the first
> token fails to parse, strsep() leaves split_page pointing into the
> middle of the kstrdup()'d buffer and the subsequent kfree() triggers
> a KASAN invalid-free.
>
> Keep the original pointer returned by kstrdup() and free that
> instead.
>
> Reported-by: syzbot+38bab69d2760cc99cfbe@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=38bab69d2760cc99cfbe
> Reported-by: syzbot+a4f65284f1451010b0a8@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a4f65284f1451010b0a8
> Fixes: a7339e4f5788 ("usb: gadget: f_uac2: Support multiple sampling rates")
> Assisted-by: deepseek:v4-pro
> Signed-off-by: Anuj Bolewar <bolewara@gmail.com>
> ---
> drivers/usb/gadget/function/f_uac2.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
> index 897787d0803..1ea1bedef9a 100644
> --- a/drivers/usb/gadget/function/f_uac2.c
> +++ b/drivers/usb/gadget/function/f_uac2.c
> @@ -2013,6 +2013,7 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
> { \
> struct f_uac2_opts *opts = to_f_uac2_opts(item); \
> char *split_page = NULL; \
> + char *split_page_orig = NULL; \
> int ret = -EINVAL; \
> char *token; \
> u32 num; \
> @@ -2026,7 +2027,7 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
> \
> i = 0; \
> memset(opts->name##s, 0x00, sizeof(opts->name##s)); \
> - split_page = kstrdup(page, GFP_KERNEL); \
> + split_page_orig = split_page = kstrdup(page, GFP_KERNEL); \
> while ((token = strsep(&split_page, ",")) != NULL) { \
> ret = kstrtou32(token, 0, &num); \
> if (ret) \
> @@ -2037,7 +2038,7 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
> }; \
> \
> end: \
> - kfree(split_page); \
> + kfree(split_page_orig); \
> mutex_unlock(&opts->lock); \
> return ret; \
> } \
>
> --
> 2.53.0
>
>
Does not apply to the usb-linus branch :(
next prev parent reply other threads:[~2026-11-20 9:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 17:43 [PATCH 0/2] usb: gadget: f_uac1/f_uac2: fix invalid-free in srate configfs store Anuj Bolewar via B4 Relay
2026-08-04 17:43 ` [PATCH 1/2] usb: gadget: f_uac2: " Anuj Bolewar via B4 Relay
2026-11-20 9:51 ` Greg Kroah-Hartman [this message]
2026-08-04 17:43 ` [PATCH 2/2] usb: gadget: f_uac1: " Anuj Bolewar via B4 Relay
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=2026112000-shed-motor-c5f0@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=bolewara@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+38bab69d2760cc99cfbe@syzkaller.appspotmail.com \
--cc=syzbot+a4f65284f1451010b0a8@syzkaller.appspotmail.com \
/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