From: Rahul Priolkar <rahul.priolkar@asu.edu>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Neill Kapron <nkapron@google.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] usb: gadget: configfs extended property reads can use freed storage
Date: Thu, 03 Dec 2026 08:21:21 -0800 (PST) [thread overview]
Message-ID: <6b119701.352d1d53.1eec8f.8089@mx.google.com> (raw)
Hello,
We first saw these KASAN reports on Linux v7.4-rc4 while testing the
configfs handlers for USB OS descriptor extended properties. We used
an unbound gadget configured by root in an x86_64 KVM guest.
We repeated the tests on v7.4-rc5 (fe6ff8d5d675). On that kernel,
KASAN reported 52 double frees in ext_prop_data_store(). In
ext_prop_data_show() it reported 60 use-after-free reads and 50
out-of-bounds reads. In 33 reads, the property returned unrelated
bytes. The rc5 build included the zero-termination fix in 7a7d9a926501.
When we ran the operations one at a time, each control ran for 60
seconds without a KASAN report.
In the rc4 double-free trace, ext_prop_data_store() appears on the
allocation stack and on both free stacks. The two read traces show
different failures: a 4,000-byte read from a freed 4,096-byte region and
a 20-byte read from the start of a 10-byte allocation.
The logs below are from the original v7.4-rc4 runs. Some end partway through the report.
Double free in ext_prop_data_store()
[ 146.042764][ T4468] BUG: KASAN: double-free in ext_prop_data_store+0x154/0x3a0
[ 146.042776][ T4468] Free of addr ffff888028e3a800 by task control-r4-gadg/4468
[ 146.042784][ T4468]
[ 146.042790][ T4468] CPU: 0 UID: 0 PID: 4468 Comm: control-r4-gadg Tainted: G B 7.4.0-rc4 #2 PREEMPT(full)
[ 146.042805][ T4468] Tainted: [B]=BAD_PAGE
[ 146.042809][ T4468] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 146.042818][ T4468] Call Trace:
[ 146.042822][ T4468] <TASK>
[ 146.042827][ T4468] dump_stack_lvl+0xe8/0x150
[ 146.042845][ T4468] print_address_description+0x55/0x1e0
[ 146.042862][ T4468] print_report+0x58/0x70
[ 146.042888][ T4468] kasan_report_invalid_free+0xea/0x110
[ 146.042932][ T4468] check_slab_allocation+0xbc/0xe0
[ 146.042947][ T4468] kfree+0x17a/0x650
[ 146.042991][ T4468] ext_prop_data_store+0x154/0x3a0
[ 146.043019][ T4468] configfs_write_iter+0x33c/0x430
[ 146.043036][ T4468] vfs_write+0x617/0xba0
[ 146.043148][ T4468] __x64_sys_pwrite64+0x215/0x2d0
[ 146.043237][ T4468] do_syscall_64+0x171/0x540
[ 146.043281][ T4468] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 146.043293][ T4468] RIP: 0033:0x4577e2
[ 146.043302][ T4468] Code: 08 0f 85 11 e3 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3>
[ 146.043312][ T4468] RSP: 002b:00007f4169302138 EFLAGS: 00000246 ORIG_RAX: 0000000000000012
[ 146.043324][ T4468] RAX: ffffffffffffffda RBX: 0000000000000075 RCX: 00000000004577e2
[ 146.043332][ T4468] RDX: 0000000000000076 RSI: 00000000004e3c20 RDI: 0000000000000004
[ 146.043340][ T4468] RBP: 00007f4169302160 R08: 0000000000000000 R09: 0000000000000000
[ 146.043348][ T4468] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000004
[ 146.043356][ T4468] R13: 0000000000000001 R14: 0000000000000011 R15: 00007ffec01deb87
[ 146.043374][ T4468] </TASK>
[ 146.043379][ T4468]
[ 146.043382][ T4468] Allocated by task 4468:
[ 146.043387][ T4468] kasan_save_track+0x3f/0x90
[ 146.043397][ T4468] __kasan_kmalloc+0x93/0xb0
[ 146.043409][ T4468] __kmalloc_node_track_caller_noprof+0x4db/0x750
[ 146.043427][ T4468] kmemdup_noprof+0x30/0x70
[ 146.043441][ T4468] ext_prop_data_store+0xbb/0x3a0
[ 146.043452][ T4468] configfs_write_iter+0x33c/0x430
[ 146.043464][ T4468] vfs_write+0x617/0xba0
[ 146.043480][ T4468] __x64_sys_pwrite64+0x215/0x2d0
[ 146.043498][ T4468] do_syscall_64+0x171/0x540
[ 146.043512][ T4468] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 146.043524][ T4468]
[ 146.043527][ T4468] Freed by task 4469:
[ 146.043532][ T4468] kasan_save_track+0x3f/0x90
[ 146.043542][ T4468] kasan_save_free_info+0x40/0x50
[ 146.043564][ T4468] __kasan_slab_free+0x70/0x90
[ 146.043575][ T4468] kfree+0x1cc/0x650
[ 146.043589][ T4468] ext_prop_data_store+0x154/0x3a0
[ 146.043600][ T4468] configfs_write_iter+0x33c/0x430
[ 146.043612][ T4468] vfs_write+0x617/0xba0
[ 146.043628][ T4468] __x64_sys_pwrite64+0x215/0x2d0
[ 146.043645][ T4468] do_syscall_64+0x171/0x540
[ 146.043660][ T4468] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 146.043671][ T4468]
[ 146.043674][ T4468] The buggy address belongs to the object at ffff888028e3a800
[ 146.043674][ T4468] which belongs to the cache kmalloc-128 of size 128
[ 146.043683][ T4468] The buggy address is located 0 bytes inside of
[ 146.043683][ T4468] 128-byte region [ffff888028e3a800, ffff888028e3a880)
[ 146.043695][ T4468]
[ 146.043698][ T4468] The buggy address belongs to the physical page:
[ 146.043702][ T4468] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x28e3a
[ 146.043712][ T4468] flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
[ 146.043721][ T4468] page_type: f5(slab)
[ 146.043730][ T4468] raw: 00fff00000000000 ffff88801bc42a00 dead000000000100 dead000000000122
[ 146.043741][ T4468] raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
[ 146.043748][ T4468] page dumped because: kasan: bad access detected
[ 146.043753][ T4468]
[ 146.043756][ T4468] Memory state around the buggy address:
[ 146.043762][ T4468] ffff888028e3a700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 fc
[ 146.043773][ T4468] ffff888028e3a780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
Use-after-free read in ext_prop_data_show()
[ 84.159739][ T4431] BUG: KASAN: slab-use-after-free in ext_prop_data_show+0xcb/0x120
[ 84.159752][ T4431] Read of size 4000 at addr ffff88802a2f4000 by task control-r4-gadg/4431
[ 84.159762][ T4431]
[ 84.159768][ T4431] CPU: 2 UID: 0 PID: 4431 Comm: control-r4-gadg Tainted: G B 7.4.0-rc4 #2 PREEMPT(full)
[ 84.159784][ T4431] Tainted: [B]=BAD_PAGE
[ 84.159789][ T4431] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 84.159797][ T4431] Call Trace:
[ 84.159802][ T4431] <TASK>
[ 84.159807][ T4431] dump_stack_lvl+0xe8/0x150
[ 84.159825][ T4431] print_address_description+0x55/0x1e0
[ 84.159854][ T4431] print_report+0x58/0x70
[ 84.159869][ T4431] kasan_report+0x117/0x150
[ 84.159903][ T4431] kasan_check_range+0x3c7/0x3f0
[ 84.159931][ T4431] __asan_memcpy+0x29/0x70
[ 84.159951][ T4431] ext_prop_data_show+0xcb/0x120
[ 84.159977][ T4431] configfs_read_iter+0x2bc/0x630
[ 84.159994][ T4431] vfs_read+0x59a/0xa80
[ 84.160160][ T4431] ksys_read+0x155/0x270
[ 84.160249][ T4431] do_syscall_64+0x171/0x540
[ 84.160293][ T4431] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 84.160306][ T4431] RIP: 0033:0x4577e2
[ 84.160315][ T4431] Code: 08 0f 85 11 e3 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3>
[ 84.160325][ T4431] RSP: 002b:00007f78f6107118 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 84.160337][ T4431] RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00000000004577e2
[ 84.160346][ T4431] RDX: 0000000000002000 RSI: 00007f78f61076a0 RDI: 0000000000000005
[ 84.160354][ T4431] RBP: 00007f78f6107140 R08: 0000000000000000 R09: 0000000000000000
[ 84.160362][ T4431] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000021
[ 84.160370][ T4431] R13: 00007ffef76e3680 R14: 00007f78f61076a0 R15: 00007ffef76e3777
[ 84.160390][ T4431] </TASK>
[ 84.160394][ T4431]
[ 84.160397][ T4431] Allocated by task 4430:
[ 84.160403][ T4431] kasan_save_track+0x3f/0x90
[ 84.160413][ T4431] __kasan_kmalloc+0x93/0xb0
[ 84.160424][ T4431] __kmalloc_node_track_caller_noprof+0x4db/0x750
[ 84.160443][ T4431] kmemdup_noprof+0x30/0x70
[ 84.160458][ T4431] ext_prop_data_store+0xbb/0x3a0
[ 84.160469][ T4431] configfs_write_iter+0x33c/0x430
[ 84.160482][ T4431] vfs_write+0x617/0xba0
[ 84.160498][ T4431] __x64_sys_pwrite64+0x215/0x2d0
[ 84.160516][ T4431] do_syscall_64+0x171/0x540
[ 84.160530][ T4431] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 84.160542][ T4431]
[ 84.160545][ T4431] Freed by task 4430:
[ 84.160550][ T4431] kasan_save_track+0x3f/0x90
[ 84.160561][ T4431] kasan_save_free_info+0x40/0x50
[ 84.160577][ T4431] __kasan_slab_free+0x70/0x90
[ 84.160588][ T4431] kfree+0x1cc/0x650
[ 84.160602][ T4431] ext_prop_data_store+0x154/0x3a0
[ 84.160613][ T4431] configfs_write_iter+0x33c/0x430
[ 84.160626][ T4431] vfs_write+0x617/0xba0
[ 84.160642][ T4431] __x64_sys_pwrite64+0x215/0x2d0
[ 84.160659][ T4431] do_syscall_64+0x171/0x540
[ 84.160674][ T4431] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 84.160686][ T4431]
[ 84.160689][ T4431] The buggy address belongs to the object at ffff88802a2f4000
[ 84.160689][ T4431] which belongs to the cache kmalloc-4k of size 4096
[ 84.160699][ T4431] The buggy address is located 0 bytes inside of
[ 84.160699][ T4431] freed 4096-byte region [ffff88802a2f4000, ffff88802a2f5000)
[ 84.160711][ T4431]
[ 84.160714][ T4431] The buggy address belongs to the physical page:
[ 84.160719][ T4431] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2a2f0
[ 84.160730][ T4431] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
[ 84.160739][ T4431] flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
[ 84.160749][ T4431] page_type: f5(slab)
[ 84.160759][ T4431] raw: 00fff00000000040 ffff88801bc43040 dead000000000100 dead000000000122
[ 84.160770][ T4431] raw: 0000000000000000 0000000000040004 00000000f5000000 0000000000000000
[ 84.160782][ T4431] head: 00fff00000000040 ffff88801bc43040 dead000000000100 dead000000000122
[ 84.160793][ T4431] head: 0000000000000000 0000000000040004 00000000f5000000 0000000000000000
[ 84.160804][ T4431] head: 00fff00000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
[ 84.160815][ T4431] head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
Out-of-bounds read in ext_prop_data_show()
[ 268.458293][ T4505] BUG: KASAN: slab-out-of-bounds in ext_prop_data_show+0xcb/0x120
[ 268.458311][ T4505] Read of size 20 at addr ffff8880227f8ae0 by task control-r4-gadg/4505
[ 268.458325][ T4505]
[ 268.458334][ T4505] CPU: 2 UID: 0 PID: 4505 Comm: control-r4-gadg Tainted: G B 7.4.0-rc4 #2 PREEMPT(full)
[ 268.458355][ T4505] Tainted: [B]=BAD_PAGE
[ 268.458362][ T4505] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 268.458373][ T4505] Call Trace:
[ 268.458379][ T4505] <TASK>
[ 268.458386][ T4505] dump_stack_lvl+0xe8/0x150
[ 268.458411][ T4505] print_address_description+0x55/0x1e0
[ 268.458450][ T4505] print_report+0x58/0x70
[ 268.458470][ T4505] kasan_report+0x117/0x150
[ 268.458514][ T4505] kasan_check_range+0x3c7/0x3f0
[ 268.458552][ T4505] __asan_memcpy+0x29/0x70
[ 268.458578][ T4505] ext_prop_data_show+0xcb/0x120
[ 268.458613][ T4505] configfs_read_iter+0x2bc/0x630
[ 268.458637][ T4505] vfs_read+0x59a/0xa80
[ 268.458855][ T4505] ksys_read+0x155/0x270
[ 268.458972][ T4505] do_syscall_64+0x171/0x540
[ 268.459031][ T4505] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 268.459048][ T4505] RIP: 0033:0x4577e2
[ 268.459060][ T4505] Code: 08 0f 85 11 e3 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3>
[ 268.459074][ T4505] RSP: 002b:00007ffe86b8e1a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 268.459091][ T4505] RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00000000004577e2
[ 268.459103][ T4505] RDX: 0000000000002000 RSI: 00000000004dfac0 RDI: 0000000000000006
[ 268.459114][ T4505] RBP: 00007ffe86b8e1d0 R08: 0000000000000000 R09: 0000000000000000
[ 268.459125][ T4505] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe86b8e240
[ 268.459136][ T4505] R13: 00007ffe86b8ff72 R14: 00000000004dfac0 R15: 0000000000000002
[ 268.459161][ T4505] </TASK>
[ 268.459167][ T4505]
[ 268.459171][ T4505] Allocated by task 4505:
[ 268.459179][ T4505] kasan_save_track+0x3f/0x90
[ 268.459192][ T4505] __kasan_kmalloc+0x93/0xb0
[ 268.459203][ T4505] __kmalloc_node_track_caller_noprof+0x4db/0x750
[ 268.459222][ T4505] kmemdup_noprof+0x30/0x70
[ 268.459238][ T4505] ext_prop_data_store+0xbb/0x3a0
[ 268.459252][ T4505] configfs_write_iter+0x33c/0x430
[ 268.459269][ T4505] vfs_write+0x617/0xba0
[ 268.459291][ T4505] ksys_write+0x155/0x270
[ 268.459314][ T4505] do_syscall_64+0x171/0x540
[ 268.459334][ T4505] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 268.459349][ T4505]
[ 268.459354][ T4505] The buggy address belongs to the object at ffff8880227f8ae0
[ 268.459354][ T4505] which belongs to the cache kmalloc-16 of size 16
[ 268.459367][ T4505] The buggy address is located 0 bytes inside of
[ 268.459367][ T4505] allocated 10-byte region [ffff8880227f8ae0, ffff8880227f8aea)
[ 268.459384][ T4505]
[ 268.459388][ T4505] The buggy address belongs to the physical page:
[ 268.459396][ T4505] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880227f8ce0 pfn:0x227f8
[ 268.459410][ T4505] flags: 0xfff00000000200(workingset|node=0|zone=1|lastcpupid=0x7ff)
[ 268.459423][ T4505] page_type: f5(slab)
[ 268.459438][ T4505] raw: 00fff00000000200 ffff88801bc42640 ffff88801bc40408 ffffea0000808fd0
[ 268.459453][ T4505] raw: ffff8880227f8ce0 0000000000800072 00000000f5000000 0000000000000000
[ 268.459462][ T4505] page dumped because: kasan: bad access detected
[ 268.459469][ T4505]
[ 268.459473][ T4505] Memory state around the buggy address:
[ 268.459481][ T4505] ffff8880227f8980: 00 03 fc fc fa fb fc fc 00 05 fc fc fa fb fc fc
[ 268.459493][ T4505] ffff8880227f8a00: 00 03 fc fc fa fb fc fc 00 00 fc fc fa fb fc fc
[ 268.459504][ T4505] >ffff8880227f8a80: 00 07 fc fc fa fb fc fc 00 04 fc fc 00 02 fc fc
[ 268.459514][ T4505] ^
[ 268.459523][ T4505] ffff8880227f8b00: 00 03 fc fc fa fb fc fc 00 06 fc fc fa fb fc fc
[ 268.459534][ T4505] ffff8880227f8b80: 00 04 fc fc fa fb fc fc 00 03 fc fc fa fb fc fc
[ 268.459543][ T4505] ==================================================================
[ 268.470996][ T4505] ==================================================================
Saved diagnostic from the C39-usb-gadget-ext-prop-unlocked test record
BUG: KASAN: double-free in ext_prop_data_store+0x154/0x3a0
Free of addr ffff88802de97400 by task control-gadget-/4407
CPU: 1 UID: 0 PID: 4407 Comm: control-gadget- Not tainted 7.4.0-rc4 #2 PREEMPT(full)
Call Trace:
kfree+0x17a/0x650
ext_prop_data_store+0x154/0x3a0
configfs_write_iter+0x33c/0x430
vfs_write+0x617/0xba0
__x64_sys_pwrite64+0x215/0x2d0
do_syscall_64+0x171/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Allocated by task 4407:
__kmalloc_node_track_caller_noprof+0x4db/0x750
kmemdup_noprof+0x30/0x70
ext_prop_data_store+0xbb/0x3a0
configfs_write_iter+0x33c/0x430
vfs_write+0x617/0xba0
__x64_sys_pwrite64+0x215/0x2d0
do_syscall_64+0x171/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 4408:
kfree+0x1cc/0x650
ext_prop_data_store+0x154/0x3a0
configfs_write_iter+0x33c/0x430
vfs_write+0x617/0xba0
__x64_sys_pwrite64+0x215/0x2d0
do_syscall_64+0x171/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88802de97400
which belongs to the cache kmalloc-96 of size 96
Can you confirm that this is a bug in USB gadget configfs?
Thanks,
Rahul Priolkar
reply other threads:[~2026-12-03 16:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=6b119701.352d1d53.1eec8f.8089@mx.google.com \
--to=rahul.priolkar@asu.edu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.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