Skip to content

[Bug] Legacy USB CDC VCOM uses rt_ringbuffer as rt_serial_rx_fifo with Serial V2 #11739

Closed

Description

@Finder16

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

Activity

  1. added
    bugThis PR/issue is a bug in the current code.
    on Aug 23, 2026
  2. github-actions commented on Aug 23, 2026

    @github-actions

    如需认领并处理此 Issue,请评论 /claim。

    To claim and work on this issue, comment /claim.

  3. Finder16 commented on Aug 29, 2026

    @Finder16
    ContributorAuthor

    /claim

  4. github-actions commented on Aug 29, 2026

    @github-actions

    @Finder16 has claimed this issue.

  5. added a commit that references this issue on Oct 11, 2026
    8a3ca7b
  6. added a commit that references this issue on Oct 12, 2026
    a550889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions