RT-Thread / RT-Thread/rt-thread
[Bug] Legacy USB CDC VCOM uses rt_ringbuffer as rt_serial_rx_fifo with Serial V2
@Finder16 is already working on this.
Since Aug 29, 2026.
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
Description
RT-Thread Version
v5.3.0
Affected area
Device drivers
Hardware/BSP vendor
Not applicable / Other
Architecture
Not applicable / Other
Board and hardware details
Not board-specific. The issue is in the common legacy USB CDC VCOM and Serial V2 code. It can affect BSPs that provide a USB device controller with RT_USB_DEVICE_CDC and RT_USING_SERIAL_V2 enabled
Develop Toolchain
Other
Describe the bug
When RT_USB_DEVICE_CDC and RT_USING_SERIAL_V2 are enabled, _function_enable() replaces serial_rx with the address of an embedded struct rt_ringbuffer:
data->serial.serial_rx = &data->rx_ringbuffer;
Serial V2 later interprets serial_rx as a struct rt_serial_rx_fifo *. Although rt_ringbuffer is the first member of rt_serial_rx_fifo, the embedded VCOM ring buffer is not contained in an rt_serial_rx_fifo object.
As a result, accesses to fields such as rx_cpt, rx_cpt_index, and rx_timeout go beyond data->rx_ringbuffer and can overwrite adjacent members such as data->tx_rbp. The serial close path may also call rt_free() on this embedded ring-buffer address even though it was not dynamically allocated.
The assignment can overwrite the valid RX FIFO allocated when the serial device was opened, making the problem reachable after the USB host configures the CDC device.
Contribution
Ijae Kim (ijk5201@psu.edu), Myeonghun Pak (mhun512@gmail.com), Yuho Choi (yqc5929@psu.edu), Taegyu Kim (tgkim@psu.edu)
Other additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.