<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/usb/gadget, branch linux-5.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-12-03T11:45:11Z</updated>
<entry>
<title>usb: gadget: f_hid: Fix zero length packet transfer</title>
<updated>2025-12-03T11:45:11Z</updated>
<author>
<name>William Wu</name>
</author>
<published>2025-08-26T10:28:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3248107d00948c55c5475c3efcd02ee75aaf185b'/>
<id>urn:sha1:3248107d00948c55c5475c3efcd02ee75aaf185b</id>
<content type='text'>
[ Upstream commit ed6f727c575b1eb8136e744acfd5e7306c9548f6 ]

Set the hid req-&gt;zero flag of ep0/in_ep to true by default,
then the UDC drivers can transfer a zero length packet at
the end if the hid transfer with size divisible to EPs max
packet size according to the USB 2.0 spec.

Signed-off-by: William Wu &lt;william.wu@rock-chips.com&gt;
Link: https://lore.kernel.org/r/1756204087-26111-1-git-send-email-william.wu@rock-chips.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_ncm: Fix MAC assignment NCM ethernet</title>
<updated>2025-12-03T11:45:09Z</updated>
<author>
<name>raub camaioni</name>
</author>
<published>2025-08-15T13:07:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a3f918b791cd8dd143845376ae0d58c32506b714'/>
<id>urn:sha1:a3f918b791cd8dd143845376ae0d58c32506b714</id>
<content type='text'>
[ Upstream commit 956606bafb5fc6e5968aadcda86fc0037e1d7548 ]

This fix is already present in f_ecm.c and was never
propagated to f_ncm.c

When creating multiple NCM ethernet devices
on a composite usb gadget device
each MAC address on the HOST side will be identical.
Having the same MAC on different network interfaces is bad.

This fix updates the MAC address inside the
ncm_strings_defs global during the ncm_bind call.
This ensures each device has a unique MAC.
In f_ecm.c ecm_string_defs is updated in the same way.

The defunct MAC assignment in ncm_alloc has been removed.

Signed-off-by: raub camaioni &lt;raubcameo@gmail.com&gt;
Link: https://lore.kernel.org/r/20250815131358.1047525-1-raubcameo@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_fs: Fix epfile null pointer access after ep enable.</title>
<updated>2025-12-03T11:45:06Z</updated>
<author>
<name>Owen Gu</name>
</author>
<published>2025-09-15T09:29:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b00d2572c16e8e59e979960d3383c2ae9cebd195'/>
<id>urn:sha1:b00d2572c16e8e59e979960d3383c2ae9cebd195</id>
<content type='text'>
commit cfd6f1a7b42f62523c96d9703ef32b0dbc495ba4 upstream.

A race condition occurs when ffs_func_eps_enable() runs concurrently
with ffs_data_reset(). The ffs_data_clear() called in ffs_data_reset()
sets ffs-&gt;epfiles to NULL before resetting ffs-&gt;eps_count to 0, leading
to a NULL pointer dereference when accessing epfile-&gt;ep in
ffs_func_eps_enable() after successful usb_ep_enable().

The ffs-&gt;epfiles pointer is set to NULL in both ffs_data_clear() and
ffs_data_close() functions, and its modification is protected by the
spinlock ffs-&gt;eps_lock. And the whole ffs_func_eps_enable() function
is also protected by ffs-&gt;eps_lock.

Thus, add NULL pointer handling for ffs-&gt;epfiles in the
ffs_func_eps_enable() function to fix issues

Signed-off-by: Owen Gu &lt;guhuinan@xiaomi.com&gt;
Link: https://lore.kernel.org/r/20250915092907.17802-1-guhuinan@xiaomi.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: configfs: Correctly set use_os_string at bind</title>
<updated>2025-10-29T12:59:47Z</updated>
<author>
<name>William Wu</name>
</author>
<published>2025-08-22T03:36:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b86de42c427621cf3d82eb879e60db657eb90326'/>
<id>urn:sha1:b86de42c427621cf3d82eb879e60db657eb90326</id>
<content type='text'>
[ Upstream commit e271cc0d25015f4be6c88bd7731444644eb352c2 ]

Once the use_os_string flag is set to true for some functions
(e.g. adb/mtp) which need to response the OS string, and then
if we re-bind the ConfigFS gadget to use the other functions
(e.g. hid) which should not to response the OS string, however,
because the use_os_string flag is still true, so the usb gadget
response the OS string descriptor incorrectly, this can cause
the USB device to be unrecognizable on the Windows system.

An example of this as follows:

echo 1 &gt; os_desc/use
ln -s functions/ffs.adb configs/b.1/function0
start adbd
echo "&lt;udc device&gt;" &gt; UDC   #succeed

stop adbd
rm configs/b.1/function0
echo 0 &gt; os_desc/use
ln -s functions/hid.gs0 configs/b.1/function0
echo "&lt;udc device&gt;" &gt; UDC  #fail to connect on Windows

This patch sets the use_os_string flag to false at bind if
the functions not support OS Descriptors.

Signed-off-by: William Wu &lt;william.wu@rock-chips.com&gt;
Fixes: 87213d388e92 ("usb: gadget: configfs: OS String support")
Link: https://lore.kernel.org/r/1755833769-25434-1-git-send-email-william.wu@rock-chips.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>USB: gadget: dummy-hcd: Fix locking bug in RT-enabled kernels</title>
<updated>2025-10-02T11:34:32Z</updated>
<author>
<name>Alan Stern</name>
</author>
<published>2025-09-17T13:30:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ea748ebb9084cebb329f4060e774c8a465fcbb18'/>
<id>urn:sha1:ea748ebb9084cebb329f4060e774c8a465fcbb18</id>
<content type='text'>
[ Upstream commit 8d63c83d8eb922f6c316320f50c82fa88d099bea ]

Yunseong Kim and the syzbot fuzzer both reported a problem in
RT-enabled kernels caused by the way dummy-hcd mixes interrupt
management and spin-locking.  The pattern was:

	local_irq_save(flags);
	spin_lock(&amp;dum-&gt;lock);
	...
	spin_unlock(&amp;dum-&gt;lock);
	...		// calls usb_gadget_giveback_request()
	local_irq_restore(flags);

The code was written this way because usb_gadget_giveback_request()
needs to be called with interrupts disabled and the private lock not
held.

While this pattern works fine in non-RT kernels, it's not good when RT
is enabled.  RT kernels handle spinlocks much like mutexes; in particular,
spin_lock() may sleep.  But sleeping is not allowed while local
interrupts are disabled.

To fix the problem, rewrite the code to conform to the pattern used
elsewhere in dummy-hcd and other UDC drivers:

	spin_lock_irqsave(&amp;dum-&gt;lock, flags);
	...
	spin_unlock(&amp;dum-&gt;lock);
	usb_gadget_giveback_request(...);
	spin_lock(&amp;dum-&gt;lock);
	...
	spin_unlock_irqrestore(&amp;dum-&gt;lock, flags);

This approach satisfies the RT requirements.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: stable &lt;stable@kernel.org&gt;
Fixes: b4dbda1a22d2 ("USB: dummy-hcd: disable interrupts during req-&gt;complete")
Reported-by: Yunseong Kim &lt;ysk@kzalloc.com&gt;
Closes: &lt;https://lore.kernel.org/linux-usb/5b337389-73b9-4ee4-a83e-7e82bf5af87a@kzalloc.com/&gt;
Reported-by: syzbot+8baacc4139f12fa77909@syzkaller.appspotmail.com
Closes: &lt;https://lore.kernel.org/linux-usb/68ac2411.050a0220.37038e.0087.GAE@google.com/&gt;
Tested-by: syzbot+8baacc4139f12fa77909@syzkaller.appspotmail.com
CC: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
CC: stable@vger.kernel.org
Reviewed-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Link: https://lore.kernel.org/r/bb192ae2-4eee-48ee-981f-3efdbbd0d8f0@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: dummy_hcd: remove usage of list iterator past the loop body</title>
<updated>2025-10-02T11:34:32Z</updated>
<author>
<name>Jakob Koschel</name>
</author>
<published>2025-09-17T13:30:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6070c741cc5c1f617477eaf91d3c96a41b16662c'/>
<id>urn:sha1:6070c741cc5c1f617477eaf91d3c96a41b16662c</id>
<content type='text'>
[ Upstream commit 7975f080d3557725160a878b1a64339043ba3d91 ]

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel &lt;jakobkoschel@gmail.com&gt;
Link: https://lore.kernel.org/r/20220308171818.384491-26-jakobkoschel@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Stable-dep-of: 8d63c83d8eb9 ("USB: gadget: dummy-hcd: Fix locking bug in RT-enabled kernels")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: udc: renesas_usb3: fix device leak at unbind</title>
<updated>2025-08-28T14:21:30Z</updated>
<author>
<name>Johan Hovold</name>
</author>
<published>2025-07-24T09:19:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=22ac4969dc37afff0bb8e2f978fae6dcfc5939bf'/>
<id>urn:sha1:22ac4969dc37afff0bb8e2f978fae6dcfc5939bf</id>
<content type='text'>
commit 868837b0a94c6b1b1fdbc04d3ba218ca83432393 upstream.

Make sure to drop the reference to the companion device taken during
probe when the driver is unbound.

Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb role switch")
Cc: stable@vger.kernel.org	# 4.19
Cc: Yoshihiro Shimoda &lt;yoshihiro.shimoda.uh@renesas.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Link: https://lore.kernel.org/r/20250724091910.21092-4-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget : fix use-after-free in composite_dev_cleanup()</title>
<updated>2025-08-28T14:21:23Z</updated>
<author>
<name>Tao Xue</name>
</author>
<published>2025-07-21T09:39:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dba96dfa5a0f685b959dd28a52ac8dab0b805204'/>
<id>urn:sha1:dba96dfa5a0f685b959dd28a52ac8dab0b805204</id>
<content type='text'>
commit 151c0aa896c47a4459e07fee7d4843f44c1bb18e upstream.

1. In func configfs_composite_bind() -&gt; composite_os_desc_req_prepare():
if kmalloc fails, the pointer cdev-&gt;os_desc_req will be freed but not
set to NULL. Then it will return a failure to the upper-level function.
2. in func configfs_composite_bind() -&gt; composite_dev_cleanup():
it will checks whether cdev-&gt;os_desc_req is NULL. If it is not NULL, it
will attempt to use it.This will lead to a use-after-free issue.

BUG: KASAN: use-after-free in composite_dev_cleanup+0xf4/0x2c0
Read of size 8 at addr 0000004827837a00 by task init/1

CPU: 10 PID: 1 Comm: init Tainted: G           O      5.10.97-oh #1
 kasan_report+0x188/0x1cc
 __asan_load8+0xb4/0xbc
 composite_dev_cleanup+0xf4/0x2c0
 configfs_composite_bind+0x210/0x7ac
 udc_bind_to_driver+0xb4/0x1ec
 usb_gadget_probe_driver+0xec/0x21c
 gadget_dev_desc_UDC_store+0x264/0x27c

Fixes: 37a3a533429e ("usb: gadget: OS Feature Descriptors support")
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Tao Xue &lt;xuetao09@huawei.com&gt;
Link: https://lore.kernel.org/r/20250721093908.14967-1-xuetao09@huawei.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: configfs: Fix OOB read on empty string write</title>
<updated>2025-08-28T14:21:13Z</updated>
<author>
<name>Xinyu Liu</name>
</author>
<published>2025-07-09T03:55:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=78b41148cfea2a3f04d87adf3a71b21735820a37'/>
<id>urn:sha1:78b41148cfea2a3f04d87adf3a71b21735820a37</id>
<content type='text'>
commit 3014168731b7930300aab656085af784edc861f6 upstream.

When writing an empty string to either 'qw_sign' or 'landingPage'
sysfs attributes, the store functions attempt to access page[l - 1]
before validating that the length 'l' is greater than zero.

This patch fixes the vulnerability by adding a check at the beginning
of os_desc_qw_sign_store() and webusb_landingPage_store() to handle
the zero-length input case gracefully by returning immediately.

Signed-off-by: Xinyu Liu &lt;katieeliu@tencent.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Link: https://lore.kernel.org/r/tencent_B1C9481688D0E95E7362AB2E999DE8048207@qq.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_serial: Fix race condition in TTY wakeup</title>
<updated>2025-07-17T16:25:03Z</updated>
<author>
<name>Kuen-Han Tsai</name>
</author>
<published>2025-06-17T05:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=18d58a467ccf011078352d91b4d6a0108c7318e8'/>
<id>urn:sha1:18d58a467ccf011078352d91b4d6a0108c7318e8</id>
<content type='text'>
commit c529c3730bd09115684644e26bf01ecbd7e2c2c9 upstream.

A race condition occurs when gs_start_io() calls either gs_start_rx() or
gs_start_tx(), as those functions briefly drop the port_lock for
usb_ep_queue(). This allows gs_close() and gserial_disconnect() to clear
port.tty and port_usb, respectively.

Use the null-safe TTY Port helper function to wake up TTY.

Example
  CPU1:			      CPU2:
  gserial_connect() // lock
  			      gs_close() // await lock
  gs_start_rx()     // unlock
  usb_ep_queue()
  			      gs_close() // lock, reset port.tty and unlock
  gs_start_rx()     // lock
  tty_wakeup()      // NPE

Fixes: 35f95fd7f234 ("TTY: usb/u_serial, use tty from tty_port")
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Kuen-Han Tsai &lt;khtsai@google.com&gt;
Reviewed-by: Prashanth K &lt;prashanth.k@oss.qualcomm.com&gt;
Link: https://lore.kernel.org/linux-usb/20240116141801.396398-1-khtsai@google.com/
Link: https://lore.kernel.org/r/20250617050844.1848232-2-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
