From: syzbot <syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: #syz test
Date: Sat, 01 Aug 2026 17:04:18 -0700 [thread overview]
Message-ID: <6a6e8982.2d659fcc.1d46f5.01c6.GAE@google.com> (raw)
In-Reply-To: <6a6be82a.77639fcc.3d4fd0.0012.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: #syz test
Author: rwarwatkar@gmail.com
From 89443f65c32564e688448a39ba54cd13a1f8ef67 Mon Sep 17 00:00:00 2001
From: Rituparna Warwatkar <rwarwatkar@gmail.com>
Date: Sat, 1 Aug 2026 23:38:07 +0000
Subject: [PATCH] usb: gadget: f_uac2: fix memory leak in sample rate store
f_uac2_opts_{p,c}_srate_store() duplicate the input page with kstrdup()
and then tokenize it with strsep(&split_page, ","). strsep() advances
the pointer it is given, so by the time the parsing loop finishes
split_page points at the end of the string (or NULL). The subsequent
kfree(split_page) therefore frees the wrong pointer (NULL when the
whole buffer was consumed), leaking the buffer allocated by kstrdup():
BUG: memory leak
unreferenced object 0xffff888112a01e00 (size 64):
kstrdup
f_uac2_opts_c_srate_store
configfs_write_iter
vfs_write
ksys_write
Keep the original allocation in split_page and hand a separate iterator
to strsep(), so the buffer is always freed. While at it, handle a
kstrdup() failure instead of dereferencing NULL. Both the p_srate and
c_srate attributes use the same macro and are fixed together.
Fixes: a7339e4f5788 ("usb: gadget: f_uac2: Support multiple sampling rates")
Reported-by: syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ebd045a6645cfb713c95
Signed-off-by: Rituparna Warwatkar <rwarwatkar@gmail.com>
---
drivers/usb/gadget/function/f_uac2.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 897787d0803..8facf289710 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 *rest; \
int ret = -EINVAL; \
char *token; \
u32 num; \
@@ -2027,7 +2028,12 @@ 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); \
- while ((token = strsep(&split_page, ",")) != NULL) { \
+ if (!split_page) { \
+ ret = -ENOMEM; \
+ goto end; \
+ } \
+ rest = split_page; \
+ while ((token = strsep(&rest, ",")) != NULL) { \
ret = kstrtou32(token, 0, &num); \
if (ret) \
goto end; \
--
2.47.3
next prev parent reply other threads:[~2026-08-02 0:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 0:11 [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store syzbot
2026-08-02 0:04 ` syzbot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-07-31 17:15 [syzbot] [usb?] memory leak in uvcg_extension_ba_source_id_store syzbot
2026-08-01 16:45 ` Forwarded: #syz test syzbot
2026-05-29 20:01 [syzbot] [netfs?] KASAN: slab-use-after-free Read in netfs_unbuffered_write syzbot
2026-05-30 2:13 ` Forwarded: #syz test syzbot
2026-04-09 18:30 [syzbot] [fuse?] BUG: scheduling while atomic in __synchronize_srcu syzbot
2026-04-13 4:40 ` Forwarded: #syz test syzbot
2026-04-13 4:49 ` syzbot
2026-04-13 4:50 ` syzbot
2026-04-13 4:52 ` syzbot
2026-04-13 5:08 ` syzbot
2026-04-13 6:04 ` syzbot
2026-04-30 16:06 ` syzbot
2026-04-30 17:26 ` syzbot
2026-04-30 17:41 ` syzbot
2026-04-30 18:27 ` syzbot
2026-04-30 18:53 ` syzbot
2025-09-30 20:29 [syzbot] [rdma?] KMSAN: uninit-value in ib_nl_handle_ip_res_resp syzbot
2025-11-06 19:45 ` Forwarded: syz test syzbot
2025-11-07 20:06 ` syzbot
2025-11-07 22:53 ` syzbot
2025-08-27 21:55 [syzbot] [mm?] [usb?] WARNING in __alloc_skb (4) syzbot
2025-09-20 10:59 ` Forwarded: syz test syzbot
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=6a6e8982.2d659fcc.1d46f5.01c6.GAE@google.com \
--to=syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.