From 21edd089a3513a977811aa0ee6d686a68c375e7b Mon Sep 17 00:00:00 2001 From: Tiejun Zhou Date: Mon, 23 Oct 2023 14:23:13 +0800 Subject: [PATCH] Improved the logic to validate object from application in ThreadX Module --- .../module_manager/inc/txm_module_manager_util.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common_modules/module_manager/inc/txm_module_manager_util.h b/common_modules/module_manager/inc/txm_module_manager_util.h index b07868a2a..db681ba90 100644 --- a/common_modules/module_manager/inc/txm_module_manager_util.h +++ b/common_modules/module_manager/inc/txm_module_manager_util.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* txm_module_manager_util.h PORTABLE C */ -/* 6.1.6 */ +/* 6.x */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -44,6 +44,9 @@ /* 04-02-2021 Scott Larson Modified comment(s) and */ /* optimized object checks, */ /* resulting in version 6.1.6 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s) and */ +/* improved object check, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ @@ -100,13 +103,15 @@ /* 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_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)) /* Strings we dereference can be in RW/RO/Shared areas. */