Zephyr
Управление объектами пользовательского режима в ядре Zephyr может освобождать объекты потоков и стеков, пока ядро всё ещё их использует, что является ошибкой использования после освобождения (use-after-free). Локальный пользователь с низкими привилегиями без взаимодействия с пользователем может вызвать её через системные вызовы из пользовательского потока, имеющего пул ресурсов, что может нарушить конфиденциальность, целостность и доступность.
Резюме сгенерировано ИИ по данным источников и переведено автоматически.
Затрагивает Zephyr начиная с версии 1.12.0, только в сборках с включёнными CONFIG_USERSPACE и CONFIG_DYNAMIC_OBJECTS. Исправленная версия в проверенных фактах не указана.
Пользовательский поток может читать и записывать память кучи ядра, к которой у него никогда не было доступа, перезаписывать данные ядра и контролировать struct k_thread, используемую планировщиком, нарушая целостность ядра и изоляцию пользовательского режима.
Исправленная версия не указана.
| zephyr | с 1.12.0 |
Команды, собирающие Zephyr версии 1.12.0 или новее с включёнными CONFIG_USERSPACE и CONFIG_DYNAMIC_OBJECTS, где пользовательские потоки создают потоки на динамических стеках или объектах.
Динамические объекты потоков и стеков могут быть освобождены, пока их поток всё ещё выполняется или завершается, что является использованием после освобождения (use-after-free). Затем пользовательский поток может читать и записывать память кучи ядра, к которой у него никогда не было доступа, перезаписывать данные ядра и контролировать struct k_thread, используемую планировщиком.
Проверенные факты указывают Zephyr начиная с версии 1.12.0. Для ошибки требуются CONFIG_USERSPACE и CONFIG_DYNAMIC_OBJECTS, а также пользовательский поток с пулом ресурсов. Вы можете проверить конфигурацию сборки на наличие этих двух опций и используемую версию Zephyr.
Проверенные факты не называют исправленную версию и идентификаторы патчей вендора, поэтому на их основе нельзя указать цель обновления. Перед принятием решения об обновлении проверьте рекомендации проекта Zephyr на наличие исправления.
Проверенные факты не дают обходного решения. Для ошибки требуются и CONFIG_USERSPACE, и CONFIG_DYNAMIC_OBJECTS, поэтому эти настройки следует пересмотреть в ожидании исправления.
Оригинальный заголовок: Zephyr kernel memory corruption in thread and stack objects
In the kernel's user-mode object management, unref_check() in kernel/userspace/userspace.c frees a dynamically allocated kernel object as soon as its permission bitmap becomes empty. It does not check the object type or whether the kernel still uses the object. k_thread_create() keeps pointers to a dynamic struct k_thread (from k_object_alloc(K_OBJ_THREAD)) and a dynamic stack (from k_object_alloc_size(K_OBJ_THREAD_STACK_ELEMENT, ...) or k_thread_stack_alloc() with K_USER) for the whole life of the thread, but nothing in the bitmap records this. z_thread_user_init() gives the new thread permission on its own thread object only, not on its stack. When the thread terminates, halt_thread() calls z_thread_release(), and its z_thread_user_exit() drops all of the thread's permissions. If that leaves the bitmap empty, the thread's own struct k_thread (and a stack it holds the last permission on) is freed before the abort path and the context switch are done with it. Any user thread with a resource pool can trigger this through syscalls it is allowed to make. If it creates a thread on a dynamic stack and then calls k_object_release() on the stack, or exits, the stack block is freed while the child still runs on it. With CONFIG_GEN_PRIV_STACKS that block also holds the privileged stack and z_stack_data, and the child keeps user-mode access to it. Once the creator has released a dynamic thread object, the thread itself can call k_object_release() on its own thread object and free its struct k_thread while it is running. z_vrfy_k_object_release() checks only that the caller holds permission on the object. If the creator has dropped its permissions, the child's ordinary termination frees the thread object inside halt_thread(). The kernel then still reads and writes the freed memory: thread->stack_obj, the thread state, swap_retval and switch_handle, and CPUs waiting for the halt spin on it. On SMP builds, another CPU can reallocate the memory in that window. All of this needs CONFIG_USERSPACE and CONFIG_DYNAMIC_OBJECTS. Freed blocks go back to the thread's resource pool, which also serves later kernel allocations such as other dynamic kernel objects and their metadata. A user thread can then read and write kernel heap memory it was never granted, overwrite kernel data later placed there, or control the contents of a struct k_thread that the scheduler still uses. This breaks kernel integrity (P1) and user-mode isolation (P2) from an unprivileged user thread. The supervisor-only k_object_free() states that it is not exposed to user mode because the kernel cannot tell whether an object is still in use, and k_thread_stack_free() refuses to free a stack in use. Dropping permissions gets around both.