[Bug] block: devfs ioctl copies partition data to an unvalidated user-supplied kernel pointer
Maintainer thường phản hồi trong vòng 2 ngày
@liangzhan5 đang làm issue này rồi.
Từ ngày 30/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
RT-Thread Version
master (v5.4.0-dev), and releases v5.2.0 through v5.3.0 (introduced with the common block layer in c424cb818695).
Affected area
- Device drivers (block layer / DFS devfs fops)
Hardware-BSP vendor
Other (verified on QEMU vexpress-a9; applies to RT-Smart targets exposing block partitions)
Architecture
- ARM / ARMv7-A
- Other (RT-Smart MMU configurations using the common block layer)
Board and hardware details
RT-Smart ARMv7-A QEMU vexpress-a9, 32-bit, with an SD image. The kernel creates /dev/sd0.
Develop Toolchain
Official RT-Thread musl ARM toolchain, GCC 7.3.0; QEMU 9.2.3 and gdb-multiarch.
Describe the bug
An unprivileged RT-Smart process can pass a kernel pointer to a block-device ioctl. sys_ioctl() and blk_fops_ioctl() forward the raw argument without copy-in/out, and blk_dev_control() handles RT_DEVICE_CTRL_BLK_PARTITION by doing:
rt_memcpy(args, &blk->partition, sizeof(blk->partition));
args is therefore an attacker-selected kernel destination for a 24-byte write. The branch also leaves err as -RT_EINVAL, so the syscall returns -1 even after the write succeeds.
Reproduction:
- Build the audited 32-bit RT-Smart vexpress kernel and an SD image containing
/dev/sd0. - Run this unprivileged user program as
/sbin/init:
fd = open("/dev/sd0", O_RDWR);
ioctl(fd, RT_DEVICE_CTRL_BLK_PARTITION, KERNEL_ADDRESS);
- GDB captured
rt_memcpy(dst=0xc00fa484, src=0xc0124cb0, count=24)through:
blk_dev_control -> rt_device_control -> dfs_devfs_ioctl
-> dfs_file_ioctl -> ioctl -> sys_ioctl -> vector_swi
The target changed from all zeros to:
00000000 00000000 00000000 00000000 00020000 c0124bf4
- A second variant targeted
rt_memcpyitself. GDB showed its first 24 bytes replaced by the same partition data; the next invocation stopped running.
The control group used a normal RT_DEVICE_CTRL_BLK_GETGEOME with a user buffer, returned sector_count=0x20000, bytes_per_sector=0x200, block_size=0x200, and the kernel remained alive.
Expected result: reject kernel pointers and copy user ioctl arguments through bounded kernel buffers. RT_DEVICE_CTRL_BLK_PARTITION must not write directly to the raw caller pointer.
Actual result: an unprivileged local process can write a kernel partition structure to an arbitrary kernel address, including writable kernel text, causing integrity violation or kernel death.
Other additional context
- CVSS 3.1:
AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H= 7.1 High - CWE-787 / CWE-668
- Attack premise: unprivileged local RT-Smart user process; no special privileges. The target must expose a block partition through devfs.
- This is an incomplete-fix sibling of #11937. #11937 fixes the tty sink of the raw
sys_ioctlpointer path; this block sink remains unfixed. - Distinguished from #11260/#11271/#11286, which concern GPT/MBR partition geometry parsing rather than the ioctl pointer boundary.
- Full QEMU logs and GDB transcripts are available on request.
- Ngôn ngữ chính
- C
- Star
- 12.4k
- Fork
- 5.5k
- Merge trung bình
- 3 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của RT-Thread/rt-thread
-
[Bug] Out-of-bounds stack read and callback signature mismatch in TM4C123 ADC driver (drv_adc.c)Đang mởbug Component component: drivers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
RT-Thread/rt-thread#12118 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BSP BSP: NXP bug Component component: drivers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
RT-Thread/rt-thread#12117 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BSP BSP: GD32 bug Component component: drivers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
RT-Thread/rt-thread#12115 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Arch: ARM/AArch64 BSP BSP: GD32 bug Component component: drivers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
RT-Thread/rt-thread#12109 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
action bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
RT-Thread/rt-thread#12106 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của RT-Thread/rt-thread
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
signalwire/freeswitch#3329 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Status: Opened
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
espressif/esp-protocols#1224 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bot-triaged module: bfloat16 module: cuda module: half module: numerical-stability triage review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày