My First CVE - CVE-2026-23275 - io uring resize and taskrun race condition
Author: 堇姬 Naup (naup96321)
前言
人生的第一個 CVE
https://www.cve.org/CVERecord/?id=CVE-2026-23275
io uring
io_uring 的核心設計目標是減少 I/O 操作所需的 syscall 次數,透過批次處理來提升效能。它維護兩個環形 buffer:
- SQ(Submission Queue):使用者提交 I/O 請求的佇列
- CQ(Completion Queue):kernel 完成 I/O 後寫入結果的佇列
基本操作流程如下:
- 設置 io_uring 運作模式
- 填寫 SQE(Submission Queue Entry),每種操作有對應的 opcode
- 通知 io_uring 處理 SQE
- 等待非同步 I/O 完成
通過 syscall call 後
1 | static inline int io_uring_register(int fd, unsigned opcode, const void *arg, |
https://elixir.bootlin.com/linux/v6.19.3/source/io_uring/register.c#L898
switch case 通過 opcode 轉發
https://elixir.bootlin.com/linux/v6.19.3/source/io_uring/register.c#L611
1 | case IORING_REGISTER_RESIZE_RINGS: |
這段簡單來說會去 free 舊的操作,然後去創建新的 cq 跟 sq ring,並初始化 ring metadata
1 | static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) |
之後去上鎖
mmap 會去上鎖,因為後續會把它 mumap
spin lock completion_lock
並保存 old rings
1 | mutex_lock(&ctx->mmap_lock); |
這部分會 上 spin lock 來防止對 ctx->rings 訪問
但我沒看到他有想去持鎖,因此導致非法的訪問了 nullptr
1 | hrtimer_interrupt (hard IRQ) |
建立一個 io_uring,啟用 DEFER_TASKRUN + TASKRUN_FLAG,並提交一個 timerfd POLL_ADD 任務
timerfd 會以 hrtimer 形式周期觸發,打斷 CPU 執行上下文
同時執行 io_register_resize_rings(),在 ctx->rings 被設為 NULL 的那一小段時間內去 access 到 null pointer
race 方法就是:
用戶態不斷呼叫 IORING_REGISTER_RESIZE_RINGS resize SQ/CQ ring 大小
在這個過程中,kernel 會把 ctx->rings 設成 NULL,再分配新的 ring
timerfd 的 hrtimer 定時器會一直觸發
callback 會一路跑到 io_req_local_work_add()
一直 race 就有機會 race 到了
1 | static void io_req_local_work_add(struct io_kiocb *req, unsigned flags) |
PoC
1 |
|
crash log
1 | ~ $ /tmp/e |
after all
雖然是個影響不大的漏洞也沒辦法做後續 exploit,但還是個值得紀念的人生第一個 CVE
也感謝 @pumpkin @swing 告訴我怎麼回報給官方,linux kernel 回報真的蠻麻煩的,有一些細節要注意,不過 maintainer 回應都蠻快的,基本上 2 周內就會處理完了
最後附上一些 report 紀錄
report
mail:
https://lore.kernel.org/io-uring/959a75c9-4de5-42d1-8f43-636f4aab5df8@kernel.dk/T/#m55e4f0d4b3fa06d42c16e0b24453bbdd7dfe9671
https://lore.kernel.org/io-uring/20260309154438.28376-1-naup96721@gmail.com/
https://lore.kernel.org/io-uring/20260310145521.68268-1-axboe@kernel.dk/T/#rb546bb5196b3dc53e5870c4ce8426e63dfa83db5
stable queue:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/diff/queue-6.18/io_uring-ensure-ctx-rings-is-stable-for-task-work-flags-manipulation.patch?id=511c1f4e8933744a6e7475c5defaad673093215b
https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/diff/queue-6.19/io_uring-ensure-ctx-rings-is-stable-for-task-work-flags-manipulation.patch?id=8a41251395b824d1c2ae038b68a0d111c10bc4a2