[Bug] block: devfs ioctl copies partition data to an unvalidated user-supplied kernel pointer
維護者通常 2 天內回覆
@liangzhan5 已經在處理了。
開始於 2026年10月30日。
評估
這個 Issue 還沒有評估資料。
描述
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.
- 主要語言
- C
- 星號
- 12.4k
- 分支
- 5.5k
- 平均合併
- 3 天 13 小時
- 30 天內合併 PR
- 73
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
RT-Thread/rt-thread 的其他 Issue
-
[Bug] Out-of-bounds stack read and callback signature mismatch in TM4C123 ADC driver (drv_adc.c)未關閉bug Component component: drivers
難度 2/5 1-3 小時 新手友好度 74/100
RT-Thread/rt-thread#12118 · 1 則留言 ·
維護者通常 2 天內回覆
-
BSP BSP: NXP bug Component component: drivers
難度 2/5 1-3 小時 新手友好度 76/100
RT-Thread/rt-thread#12117 · 1 則留言 ·
維護者通常 2 天內回覆
-
BSP BSP: GD32 bug Component component: drivers
難度 2/5 1-3 小時 新手友好度 74/100
RT-Thread/rt-thread#12115 · 1 則留言 ·
維護者通常 2 天內回覆
-
Arch: ARM/AArch64 BSP BSP: GD32 bug Component component: drivers
難度 2/5 1-3 小時 新手友好度 66/100
RT-Thread/rt-thread#12109 · 5 則留言 ·
維護者通常 2 天內回覆
-
action bug
難度 2/5 1-3 小時 新手友好度 78/100
RT-Thread/rt-thread#12106 · 1 則留言 ·
維護者通常 2 天內回覆
查看 RT-Thread/rt-thread 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
signalwire/freeswitch#3329 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
維護者通常 1 天內回覆
-
Status: Opened
難度 2/5 1-3 小時 新手友好度 83/100
espressif/esp-protocols#1224 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
bot-triaged module: bfloat16 module: cuda module: half module: numerical-stability triage review
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆