Zephyrのカーネルに解放済みメモリを使う脆弱性 権限を持つ利用者が権限昇格のおそれ
Summary
ZephyrのCANドライバーで、解放されたメモリを参照する脆弱性(CWE-416)が見つかりました。CAN受信フィルターに渡したメッセージキューの寿命が管理されず、CANのデバイスへのアクセス権を持つ一般のユーザースレッドが、カーネルのメモリを書き換えるおそれがあります。影響を受けるのは4.3.2より前と4.4.0から4.5.0より前の版で、修正版は4.3.2と4.5.0です。修正版への更新を進めてください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
ZephyrのCANドライバーで、解放されたメモリを参照する脆弱性(CWE-416)が見つかりました。CAN受信フィルターに渡したメッセージキューの寿命が管理されず、CANのデバイスへのアクセス権を持つ一般のユーザースレッドが、カーネルのメモリを書き換えるおそれがあります。影響を受けるのは4.3.2より前と4.4.0から4.5.0より前の版で、修正版は4.3.2と4.5.0です。修正版への更新を進めてください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| zephyrprojectzephyr |
≥ 1.14.0, < 4.3.2→ 4.3.2 ≥ 4.4.0, < 4.5.0→ 4.5.0 |
4.3.2 4.5.0 |
Original description The description as published by the source.
The can_add_rx_filter_msgq() system call installs a CAN RX filter whose callback (can_msgq_put() in drivers/can/can_common.c) is handed the caller's struct k_msgq * as user_data. The controller driver stores that raw pointer in its filter table and dereferences it from the RX path every time a matching frame arrives. The system call verifier z_vrfy_can_add_rx_filter_msgq() in drivers/can/can_handlers.c validated the queue only with K_SYSCALL_OBJ(), which is a point-in-time check of type, initialization and caller permission and says nothing about the object's lifetime.
On a build with CONFIG_USERSPACE=y and CONFIG_DYNAMIC_OBJECTS=y, an unprivileged user-mode thread that has been granted access to a CAN device can obtain a message queue whose lifetime it fully controls: k_object_alloc(K_OBJ_MSGQ) followed by k_msgq_alloc_init(). The lifetime of such an object is driven solely by its permission bitmask, and a pointer retained by the kernel is not represented there. After registering the filter, the thread calls k_object_release() — or simply terminates — and unref_check() frees the struct k_msgq storage while the CAN driver still holds the pointer.
The next matching CAN frame causes k_msgq_put() to run in supervisor context against freed memory that the attacker can have groomed with another kernel allocation: the frame payload is memcpy()d through the reused block's write_ptr, and the queue's wait_q (and poll_events under CONFIG_POLL) list nodes are manipulated. This yields…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- patch github.com