A kernel object pointer validation flaw in ThreadX system calls allows attackers to supply kernel pointers to reserved memory regions. This can cause the kernel to access invalid memory when reading the object’s type ID, resulting in a system exception and a denial-of-service (DoS) condition.
In ThreadX, many system calls that accept kernel object pointers only check whether the pointer is outside the module memory region. However, they do not verify whether the pointer actually points to a valid kernel object or whether it falls within reserved or otherwise unmapped memory regions.
Specifically, ThreadX uses macros such as TXM_MODULE_MANAGER_PARAM_CHECK_OBJECT_FOR_USE to validate kernel object pointers passed to system calls. The relevant code is as follows:
threadx/common_modules/module_manager/inc/txm_module_manager_util.h
/* Kernel objects should be outside the module at the very least. */
#define TXM_MODULE_MANAGER_PARAM_CHECK_OBJECT_FOR_USE(module_instance, obj_ptr, obj_size) \
(TXM_MODULE_MANAGER_ENSURE_OUTSIDE_MODULE(module_instance, obj_ptr, obj_size) || \
(_txm_module_manager_created_object_check(module_instance, (void *)obj_ptr) == TX_FALSE) || \
((void *) (obj_ptr) == TX_NULL))
/* When creating an object, the object must be inside the object pool. */
#define TXM_MODULE_MANAGER_PARAM_CHECK_OBJECT_FOR_CREATION(module_instance, obj_ptr, obj_size) \
((TXM_MODULE_MANAGER_ENSURE_INSIDE_OBJ_POOL(module_instance, obj_ptr, obj_size) && \
(_txm_module_manager_object_size_check(obj_ptr, obj_size) == TX_SUCCESS)) || \
(_txm_module_manager_created_object_check(module_instance, (void *)obj_ptr) == TX_FALSE) || \
((void *) (obj_ptr) == TX_NULL))
However, there is no check to ensure that obj_ptr does not point to reserved or unmapped memory. As a result, a pointer that is outside the module region but within a reserved or invalid area will pass this check, and the kernel will later dereference it, potentially causing a system exception.
As a result, an attacker can craft a system call with a pointer that lies outside the module region but within a reserved or unmapped area of the address space. When the kernel attempts to read the type ID or other fields from this pointer, it triggers an invalid memory access (e.g., a HardFault or BusFault on ARM Cortex-M), causing the system to crash.
timer_info_get,timer_delete,timer_deactivate,timer_create,timer_change,timer_activate,thread_wait_abort,thread_time_slice_change,thread_terminate,thread_suspend,thread_resume,thread_reset,thread_relinquish,thread_priority_change,thread_preemption_change,thread_info_get,thread_entry_exit_notify,thread_delete,thread_create,semaphore_put_notify,semaphore_put,semaphore_prioritize,semaphore_info_get,semaphore_get,semaphore_delete,semaphore_create,semaphore_ceiling_put,queue_send_notify,queue_send,queue_receive,queue_prioritize,queue_info_get,queue_front_send,queue_flush,queue_delete,queue_create,mutex_put,mutex_prioritize,mutex_info_get,mutex_get,mutex_delete,mutex_create,event_flags_set_notify,event_flags_set,event_flags_info_get,event_flags_get,event_flags_delete,event_flags_create,byte_release,byte_pool_prioritize,byte_pool_info_get,byte_pool_delete,byte_pool_create,byte_allocate,block_release,block_pool_prioritize,block_pool_info_get,block_pool_delete,block_pool_create,block_allocate
Summary
A kernel object pointer validation flaw in ThreadX system calls allows attackers to supply kernel pointers to reserved memory regions. This can cause the kernel to access invalid memory when reading the object’s type ID, resulting in a system exception and a denial-of-service (DoS) condition.
Details
In ThreadX, many system calls that accept kernel object pointers only check whether the pointer is outside the module memory region. However, they do not verify whether the pointer actually points to a valid kernel object or whether it falls within reserved or otherwise unmapped memory regions.
Specifically, ThreadX uses macros such as TXM_MODULE_MANAGER_PARAM_CHECK_OBJECT_FOR_USE to validate kernel object pointers passed to system calls. The relevant code is as follows:
This macro checks that:
The object pointer is outside the module's memory region (TXM_MODULE_MANAGER_ENSURE_OUTSIDE_MODULE), but does not ensure the pointer is within a valid, mapped, and accessible kernel memory region.
The object is not already a created object (_txm_module_manager_created_object_check).
The pointer is not NULL.
However, there is no check to ensure that obj_ptr does not point to reserved or unmapped memory. As a result, a pointer that is outside the module region but within a reserved or invalid area will pass this check, and the kernel will later dereference it, potentially causing a system exception.
As a result, an attacker can craft a system call with a pointer that lies outside the module region but within a reserved or unmapped area of the address space. When the kernel attempts to read the type ID or other fields from this pointer, it triggers an invalid memory access (e.g., a HardFault or BusFault on ARM Cortex-M), causing the system to crash.
Impact
Type: Denial of Service (DoS)
Who is impacted: Any system running ThreadX where untrusted code (such as user modules or external inputs) can supply kernel object pointers to system calls.
Severity: An attacker can crash the entire system by passing a pointer to reserved memory, causing persistent denial of service until a reboot.
Affected Syscalls
The affected syscalls are as follows: