mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store
@ 2026-07-31  0:11 syzbot
  2026-08-02  0:04 ` Forwarded: #syz test syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2026-07-31  0:11 UTC (permalink / raw)
  To: gregkh, linux-kernel, linux-usb, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    3dab139d4795 Merge tag 'rust-fixes-7.2-2' of git://git.ker..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16e611b9580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ba7c2d1679fb08a2
dashboard link: https://syzkaller.appspot.com/bug?extid=ebd045a6645cfb713c95
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=166ba499580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11e611b9580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8c49d395f8d0/disk-3dab139d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/deff2ace5e6a/vmlinux-3dab139d.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2c90a783f940/bzImage-3dab139d.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com

2026/07/26 16:23:20 executed programs: 5
BUG: memory leak
unreferenced object 0xffff888112a01e00 (size 64):
  comm "syz.0.17", pid 5945, jiffies 4294942115
  hex dump (first 32 bytes):
    34 34 31 30 30 00 34 38 30 30 30 00 38 38 32 30  44100.48000.8820
    30 00 39 36 30 30 30 00 31 37 36 34 30 30 00 31  0.96000.176400.1
  backtrace (crc 9bbd8bc9):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4597 [inline]
    slab_alloc_node mm/slub.c:4917 [inline]
    __do_kmalloc_node mm/slub.c:5333 [inline]
    __kmalloc_node_track_caller_noprof+0x3d3/0x570 mm/slub.c:5471
    __kmemdup_nul mm/util.c:64 [inline]
    kstrdup+0x3c/0x80 mm/util.c:84
    f_uac2_opts_c_srate_store+0xbb/0x170 drivers/usb/gadget/function/f_uac2.c:2091
    flush_write_buffer fs/configfs/file.c:207 [inline]
    configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
    new_sync_write fs/read_write.c:595 [inline]
    vfs_write+0x3ac/0x720 fs/read_write.c:687
    ksys_write+0xa5/0x170 fs/read_write.c:739
    do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
    do_syscall_64+0xf8/0x610 arch/x86/entry/syscall_64.c:94
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff8881128d2d80 (size 64):
  comm "syz.0.18", pid 5946, jiffies 4294942116
  hex dump (first 32 bytes):
    34 34 31 30 30 00 34 38 30 30 30 00 38 38 32 30  44100.48000.8820
    30 00 39 36 30 30 30 00 31 37 36 34 30 30 00 31  0.96000.176400.1
  backtrace (crc 9bbd8bc9):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4597 [inline]
    slab_alloc_node mm/slub.c:4917 [inline]
    __do_kmalloc_node mm/slub.c:5333 [inline]
    __kmalloc_node_track_caller_noprof+0x3d3/0x570 mm/slub.c:5471
    __kmemdup_nul mm/util.c:64 [inline]
    kstrdup+0x3c/0x80 mm/util.c:84
    f_uac2_opts_c_srate_store+0xbb/0x170 drivers/usb/gadget/function/f_uac2.c:2091
    flush_write_buffer fs/configfs/file.c:207 [inline]
    configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
    new_sync_write fs/read_write.c:595 [inline]
    vfs_write+0x3ac/0x720 fs/read_write.c:687
    ksys_write+0xa5/0x170 fs/read_write.c:739
    do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
    do_syscall_64+0xf8/0x610 arch/x86/entry/syscall_64.c:94
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff88811193ee80 (size 64):
  comm "syz.0.21", pid 5964, jiffies 4294942644
  hex dump (first 32 bytes):
    34 34 31 30 30 00 34 38 30 30 30 00 38 38 32 30  44100.48000.8820
    30 00 39 36 30 30 30 00 31 37 36 34 30 30 00 31  0.96000.176400.1
  backtrace (crc 9bbd8bc9):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4597 [inline]
    slab_alloc_node mm/slub.c:4917 [inline]
    __do_kmalloc_node mm/slub.c:5333 [inline]
    __kmalloc_node_track_caller_noprof+0x3d3/0x570 mm/slub.c:5471
    __kmemdup_nul mm/util.c:64 [inline]
    kstrdup+0x3c/0x80 mm/util.c:84
    f_uac2_opts_c_srate_store+0xbb/0x170 drivers/usb/gadget/function/f_uac2.c:2091
    flush_write_buffer fs/configfs/file.c:207 [inline]
    configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
    new_sync_write fs/read_write.c:595 [inline]
    vfs_write+0x3ac/0x720 fs/read_write.c:687
    ksys_write+0xa5/0x170 fs/read_write.c:739
    do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
    do_syscall_64+0xf8/0x610 arch/x86/entry/syscall_64.c:94
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

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

* Forwarded: #syz test
  2026-07-31  0:11 [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store syzbot
@ 2026-08-02  0:04 ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2026-08-02  0:04 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

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


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

* Re: [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store
       [not found] <20260802000350.90671-1-rituu@riacini.speedport.ip>
@ 2026-08-02  0:34 ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2026-08-02  0:34 UTC (permalink / raw)
  To: linux-kernel, rwarwatkar, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com
Tested-by: syzbot+ebd045a6645cfb713c95@syzkaller.appspotmail.com

Tested on:

commit:         2d2338c9 Merge tag 'i2c-fixes-7.2-rc6' of git://git.ke..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15c7ee32580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ba7c2d1679fb08a2
dashboard link: https://syzkaller.appspot.com/bug?extid=ebd045a6645cfb713c95
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch:          https://syzkaller.appspot.com/x/patch.diff?x=179bee32580000

Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2026-08-02  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31  0:11 [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store syzbot
2026-08-02  0:04 ` Forwarded: #syz test syzbot
     [not found] <20260802000350.90671-1-rituu@riacini.speedport.ip>
2026-08-02  0:34 ` [syzbot] [usb?] memory leak in f_uac2_opts_c_srate_store 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®