1e41f4b71Sopenharmony_ci# LMS
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Basic Concepts
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciLite Memory Sanitizer (LMS) is a tool used to detect memory errors on a real-time basis. It can detect buffer overflow, Use-After-Free (UAF), and double free errors in real time, and notify the operating system immediately. Together with Backtrace, the LMS can locate the code line that causes the memory error. It greatly improves the efficiency of locating memory errors.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ciThe LMS module of the OpenHarmony LiteOS-M kernel provides the following functions:
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci- Supports check of multiple memory pools.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci- Checks the memory allocated by **LOS_MemAlloc**, **LOS_MemAllocAlign**, and **LOS_MemRealloc**.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci- Checks the memory when bounds-checking functions are called (enabled by default).
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci- Checks the memory when libc frequently accessed functions, including **memset**, **memcpy**, **memmove**, **strcat**, **strcpy**, **strncat** and **strncpy**, are called.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## Working Principles
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciThe LMS uses shadow memory mapping to mark the system memory state. There are three states: **Accessible**, **RedZone**, and **Freed**. The shadow memory is located in the tail of the memory pool.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci- After memory is allocated from the heap, the shadow memory in the data area is set to the **Accessible** state, and the shadow memory in the head node area is set to the **RedZone** state.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci- When memory is released from the heap, the shadow memory of the released memory is set to the **Freed** state.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci- During code compilation, a function is inserted before the read/write instructions in the code to check the address validity. The tool checks the state value of the shadow memory that accesses the memory. If the shadow memory is in the **RedZone** statue, an overflow error will be reported. If the shadow memory is in the **Freed** state, a UAF error will be reported.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci- When memory is released, the tool checks the state value of the shadow memory at the released address. If the shadow memory is in the **RedZone** state, a double free error will be reported.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci## Available APIs
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciThe LMS module of the OpenHarmony LiteOS-A kernel provides the following APIs. For more details, see [API reference](https://gitee.com/openharmony/kernel_liteos_m/blob/master/components/lms/los_lms.h).
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci**Table 1** APIs of the LMS module
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci| Category| API | Description|
39e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
40e41f4b71Sopenharmony_ci| Adding a memory pool to be checked| LOS_LmsCheckPoolAdd | Adds the address range of a memory pool to the LMS check linked list. LMS performs a validity check when the accessed address is within the linked list. In addition, **LOS_MemInit** calls this API to add the initialized memory pool to the LMS check linked list by default.|
41e41f4b71Sopenharmony_ci| Deleting a memory pool from the LMS check linked list| LOS_LmsCheckPoolDel | Cancels the validity check on the specified memory pool.|
42e41f4b71Sopenharmony_ci| Protecting a specified memory chunk| LOS_LmsAddrProtect | Locks a memory chunk to prevent it from being read or written. Once the locked memory chunk is accessed, an error will be reported.|
43e41f4b71Sopenharmony_ci| Disabling protection of a specified memory chunk| LOS_LmsAddrDisableProtect | Unlocks a memory chunk to make it readable and writable.|
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci## Development Guidelines
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci### How to Develop
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciThe typical process for enabling LMS is as follows:
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci1. Configure the macros related to the LMS module.
54e41f4b71Sopenharmony_ci   Configure the LMS macro **LOSCFG_KERNEL_LMS**, which is disabled by default. 
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci   Run the **make menuconfig** command in the **kernel/liteos_m** directory, and set **Kernel->Enable Lite Memory Sanitizer** to **YES**. If this option is unavailable, select **Enable Backtrace**.
57e41f4b71Sopenharmony_ci   
58e41f4b71Sopenharmony_ci   | Macro| menuconfig Option| Description| Value|
59e41f4b71Sopenharmony_ci   | -------- | -------- | -------- | -------- |
60e41f4b71Sopenharmony_ci   | LOSCFG_KERNEL_LMS | Enable Lms Feature | Whether to enable LMS.| YES/NO |
61e41f4b71Sopenharmony_ci   | LOSCFG_LMS_MAX_RECORD_POOL_NUM | Lms check pool max num | Maximum number of memory pools that can be checked by LMS.| INT |
62e41f4b71Sopenharmony_ci   | LOSCFG_LMS_LOAD_CHECK | Enable lms read check | Whether to enable LMS read check.| YES/NO |
63e41f4b71Sopenharmony_ci   | LOSCFG_LMS_STORE_CHECK | Enable lms write check | Whether to enable LMS write check.| YES/NO |
64e41f4b71Sopenharmony_ci   | LOSCFG_LMS_CHECK_STRICT | Enable lms strict check, byte-by-byte | Whether to enable LMS byte-by-byte check.| YES/NO |
65e41f4b71Sopenharmony_ci   
66e41f4b71Sopenharmony_ci2. Modify the build script of the target module.
67e41f4b71Sopenharmony_ci   Add **-fsanitize=kernel-address** to insert memory access checks, and add **-O0** to disable optimization performed by the compiler.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci   The modifications vary depending on the compiler (GCC or Clang) used. The following is an example:
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci   ```
72e41f4b71Sopenharmony_ci   if ("$ohos_build_compiler_specified" == "gcc") {
73e41f4b71Sopenharmony_ci       cflags_c = [
74e41f4b71Sopenharmony_ci       "-O0",
75e41f4b71Sopenharmony_ci       "-fsanitize=kernel-address",
76e41f4b71Sopenharmony_ci       ]
77e41f4b71Sopenharmony_ci   } else {
78e41f4b71Sopenharmony_ci       cflags_c = [
79e41f4b71Sopenharmony_ci       "-O0",
80e41f4b71Sopenharmony_ci       "-fsanitize=kernel-address",
81e41f4b71Sopenharmony_ci       "-mllvm",
82e41f4b71Sopenharmony_ci       "-asan-instrumentation-with-call-threshold=0",
83e41f4b71Sopenharmony_ci       "-mllvm",
84e41f4b71Sopenharmony_ci       "-asan-stack=0",
85e41f4b71Sopenharmony_ci       "-mllvm",
86e41f4b71Sopenharmony_ci       "-asan-globals=0",
87e41f4b71Sopenharmony_ci       ]
88e41f4b71Sopenharmony_ci   }
89e41f4b71Sopenharmony_ci   ```
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci3. Recompile the code and check the serial port output. 
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci   The memory problem detected will be displayed.
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci### Development Example
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ciThis example implements the following:
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci1. Create a task for LMS.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci2. Construct a buffer overflow error and a UAF error.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci3. Add "-fsanitize=kernel-address", execute the compilation, and check the output.
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci### Sample Code
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciThe code is as follows:
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ciThe sample code can be compiled and verified in **./kernel/liteos_m/testsuites/src/osTest.c**. The **Example_Lms_test** function is called in **TestTaskEntry**.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ciModify **./kernel/liteos_m/testsuites/BUILD.gn** corresponding to **osTest.c**.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci```
116e41f4b71Sopenharmony_ci#define PAGE_SIZE       (0x1000U)
117e41f4b71Sopenharmony_ci#define INDEX_MAX       20
118e41f4b71Sopenharmony_ciUINT32 g_lmsTestTaskId;
119e41f4b71Sopenharmony_cichar g_testLmsPool[2 * PAGE_SIZE];
120e41f4b71Sopenharmony_ciSTATIC VOID testPoolInit(void)
121e41f4b71Sopenharmony_ci{
122e41f4b71Sopenharmony_ci    UINT32 ret = LOS_MemInit(g_testLmsPool, 2 * PAGE_SIZE);
123e41f4b71Sopenharmony_ci    if (ret != 0) {
124e41f4b71Sopenharmony_ci        PRINT_ERR("%s failed, ret = 0x%x\n", __FUNCTION__, ret);
125e41f4b71Sopenharmony_ci        return;
126e41f4b71Sopenharmony_ci    }
127e41f4b71Sopenharmony_ci}
128e41f4b71Sopenharmony_cistatic VOID LmsTestOsmallocOverflow(VOID)
129e41f4b71Sopenharmony_ci{
130e41f4b71Sopenharmony_ci    PRINTK("\n######%s start ######\n", __FUNCTION__);
131e41f4b71Sopenharmony_ci    UINT32 i;
132e41f4b71Sopenharmony_ci    CHAR *str = (CHAR *)LOS_MemAlloc(g_testLmsPool, INDEX_MAX);
133e41f4b71Sopenharmony_ci    PRINTK("str[%2d]=0x%2x ", INDEX_MAX, str[INDEX_MAX]); /* trigger heap overflow at str[INDEX_MAX] */
134e41f4b71Sopenharmony_ci    PRINTK("\n######%s stop ######\n", __FUNCTION__);
135e41f4b71Sopenharmony_ci}
136e41f4b71Sopenharmony_cistatic VOID LmsTestUseAfterFree(VOID)
137e41f4b71Sopenharmony_ci{
138e41f4b71Sopenharmony_ci    PRINTK("\n######%s start ######\n", __FUNCTION__);
139e41f4b71Sopenharmony_ci    UINT32 i;
140e41f4b71Sopenharmony_ci    CHAR *str = (CHAR *)LOS_MemAlloc(g_testLmsPool, INDEX_MAX);
141e41f4b71Sopenharmony_ci    LOS_MemFree(g_testLmsPool, str);
142e41f4b71Sopenharmony_ci    PRINTK("str[%2d]=0x%2x ", 0, str[0]); /* trigger use after free at str[0] */
143e41f4b71Sopenharmony_ci    PRINTK("\n######%s stop ######\n", __FUNCTION__);
144e41f4b71Sopenharmony_ci}
145e41f4b71Sopenharmony_ciVOID LmsTestCaseTask(VOID)
146e41f4b71Sopenharmony_ci{ 
147e41f4b71Sopenharmony_ci    testPoolInit();
148e41f4b71Sopenharmony_ci    LmsTestOsmallocOverflow();
149e41f4b71Sopenharmony_ci    LmsTestUseAfterFree();
150e41f4b71Sopenharmony_ci}
151e41f4b71Sopenharmony_ciUINT32 Example_Lms_test(VOID){
152e41f4b71Sopenharmony_ci    UINT32 ret;    
153e41f4b71Sopenharmony_ci    TSK_INIT_PARAM_S lmsTestTask;    
154e41f4b71Sopenharmony_ci    /* Create a task for LMS. */   
155e41f4b71Sopenharmony_ci    memset(&lmsTestTask, 0, sizeof(TSK_INIT_PARAM_S));    
156e41f4b71Sopenharmony_ci    lmsTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)LmsTestCaseTask;
157e41f4b71Sopenharmony_ci    lmsTestTask.pcName       = "TestLmsTsk";  /* Test task name. */   				     
158e41f4b71Sopenharmony_ci    lmsTestTask.uwStackSize  = 0x800;    
159e41f4b71Sopenharmony_ci    lmsTestTask.usTaskPrio   = 5;    
160e41f4b71Sopenharmony_ci    lmsTestTask.uwResved   = LOS_TASK_STATUS_DETACHED;    
161e41f4b71Sopenharmony_ci    ret = LOS_TaskCreate(&g_lmsTestTaskId, &lmsTestTask);    
162e41f4b71Sopenharmony_ci    if(ret != LOS_OK){        
163e41f4b71Sopenharmony_ci        PRINT_ERR("LmsTestTask create failed .\n");        
164e41f4b71Sopenharmony_ci        return LOS_NOK;    
165e41f4b71Sopenharmony_ci    } 
166e41f4b71Sopenharmony_ci    return LOS_OK;
167e41f4b71Sopenharmony_ci}
168e41f4b71Sopenharmony_ci```
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci### Verification
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci  The following is an example of the command output. The data may vary depending on the running environment.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci```
176e41f4b71Sopenharmony_ci######LmsTestOsmallocOverflow start ######
177e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]*****  Kernel Address Sanitizer Error Detected Start *****
178e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Heap buffer overflow error detected
179e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Illegal READ address at: [0x21040414]
180e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Shadow memory address: [0x21041e84 : 6]  Shadow memory value: [2]
181e41f4b71Sopenharmony_cipsp, start = 21057d88, end = 21057e80
182e41f4b71Sopenharmony_citaskName = TestLmsTsk
183e41f4b71Sopenharmony_citaskID   = 5
184e41f4b71Sopenharmony_ci----- traceback start -----
185e41f4b71Sopenharmony_citraceback 0 -- lr = 0x210099f4
186e41f4b71Sopenharmony_citraceback 1 -- lr = 0x2101da6e
187e41f4b71Sopenharmony_citraceback 2 -- lr = 0x2101db38
188e41f4b71Sopenharmony_citraceback 3 -- lr = 0x2101c494
189e41f4b71Sopenharmony_ci----- traceback end -----
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci[LMS] Dump info around address [0x21040414]:
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci        [0x21040390]:  00  00  00  00  00  00  00  00 | [0x21041e7c |  4]:  1  1
194e41f4b71Sopenharmony_ci        [0x21040398]:  00  00  00  00  00  00  00  00 | [0x21041e7d |  0]:  1  1
195e41f4b71Sopenharmony_ci        [0x210403a0]:  00  00  00  00  00  00  00  00 | [0x21041e7d |  4]:  1  1
196e41f4b71Sopenharmony_ci        [0x210403a8]:  00  00  00  00  00  00  00  00 | [0x21041e7e |  0]:  1  1
197e41f4b71Sopenharmony_ci        [0x210403b0]:  00  00  00  00  00  00  00  00 | [0x21041e7e |  4]:  1  1
198e41f4b71Sopenharmony_ci        [0x210403b8]:  00  00  00  00  00  00  00  00 | [0x21041e7f |  0]:  1  1
199e41f4b71Sopenharmony_ci        [0x210403c0]:  00  00  00  00  00  00  00  00 | [0x21041e7f |  4]:  1  1
200e41f4b71Sopenharmony_ci        [0x210403c8]:  00  00  00  00  00  00  00  00 | [0x21041e80 |  0]:  1  1
201e41f4b71Sopenharmony_ci        [0x210403d0]:  00  00  00  00  00  00  00  00 | [0x21041e80 |  4]:  1  1
202e41f4b71Sopenharmony_ci        [0x210403d8]:  00  00  00  00  00  00  00  00 | [0x21041e81 |  0]:  1  1
203e41f4b71Sopenharmony_ci        [0x210403e0]:  00  00  00  00  00  00  00  00 | [0x21041e81 |  4]:  1  1
204e41f4b71Sopenharmony_ci        [0x210403e8]:  00  00  00  00  00  00  00  00 | [0x21041e82 |  0]:  1  1
205e41f4b71Sopenharmony_ci        [0x210403f0]:  00  00  00  00  00  00  00  00 | [0x21041e82 |  4]:  1  1
206e41f4b71Sopenharmony_ci        [0x210403f8]:  40  1e  04  21  05  07  00  80 | [0x21041e83 |  0]:  2  2
207e41f4b71Sopenharmony_ci        [0x21040400]:  00  00  00  00  00  00  00  00 | [0x21041e83 |  4]:  0  0
208e41f4b71Sopenharmony_ci        [0x21040408]:  00  00  00  00  00  00  00  00 | [0x21041e84 |  0]:  0  0
209e41f4b71Sopenharmony_ci        [0x21040410]:  00  00  00  00 [f8] 03  04  21 | [0x21041e84 |  4]:  0 [2]
210e41f4b71Sopenharmony_ci        [0x21040418]:  00  8b  06  00  00  00  00  00 | [0x21041e85 |  0]:  2  3
211e41f4b71Sopenharmony_ci        [0x21040420]:  00  00  00  00  00  00  00  00 | [0x21041e85 |  4]:  3  3
212e41f4b71Sopenharmony_ci        [0x21040428]:  00  00  00  00  00  00  00  00 | [0x21041e86 |  0]:  3  3
213e41f4b71Sopenharmony_ci        [0x21040430]:  00  00  00  00  00  00  00  00 | [0x21041e86 |  4]:  3  3
214e41f4b71Sopenharmony_ci        [0x21040438]:  00  00  00  00  00  00  00  00 | [0x21041e87 |  0]:  3  3
215e41f4b71Sopenharmony_ci        [0x21040440]:  00  00  00  00  00  00  00  00 | [0x21041e87 |  4]:  3  3
216e41f4b71Sopenharmony_ci        [0x21040448]:  00  00  00  00  00  00  00  00 | [0x21041e88 |  0]:  3  3
217e41f4b71Sopenharmony_ci        [0x21040450]:  00  00  00  00  00  00  00  00 | [0x21041e88 |  4]:  3  3
218e41f4b71Sopenharmony_ci        [0x21040458]:  00  00  00  00  00  00  00  00 | [0x21041e89 |  0]:  3  3
219e41f4b71Sopenharmony_ci        [0x21040460]:  00  00  00  00  00  00  00  00 | [0x21041e89 |  4]:  3  3
220e41f4b71Sopenharmony_ci        [0x21040468]:  00  00  00  00  00  00  00  00 | [0x21041e8a |  0]:  3  3
221e41f4b71Sopenharmony_ci        [0x21040470]:  00  00  00  00  00  00  00  00 | [0x21041e8a |  4]:  3  3
222e41f4b71Sopenharmony_ci        [0x21040478]:  00  00  00  00  00  00  00  00 | [0x21041e8b |  0]:  3  3
223e41f4b71Sopenharmony_ci        [0x21040480]:  00  00  00  00  00  00  00  00 | [0x21041e8b |  4]:  3  3
224e41f4b71Sopenharmony_ci        [0x21040488]:  00  00  00  00  00  00  00  00 | [0x21041e8c |  0]:  3  3
225e41f4b71Sopenharmony_ci        [0x21040490]:  00  00  00  00  00  00  00  00 | [0x21041e8c |  4]:  3  3
226e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]*****  Kernel Address Sanitizer Error Detected End *****
227e41f4b71Sopenharmony_cistr[20]=0xfffffff8
228e41f4b71Sopenharmony_ci######LmsTestOsmallocOverflow stop ######
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci######LmsTestUseAfterFree start ######
231e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]*****  Kernel Address Sanitizer Error Detected Start *****
232e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Use after free error detected
233e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Illegal READ address at: [0x2104041c]
234e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]Shadow memory address: [0x21041e85 : 2]  Shadow memory value: [3]
235e41f4b71Sopenharmony_cipsp, start = 21057d90, end = 21057e80
236e41f4b71Sopenharmony_citaskName = TestLmsTsk
237e41f4b71Sopenharmony_citaskID   = 5
238e41f4b71Sopenharmony_ci----- traceback start -----
239e41f4b71Sopenharmony_citraceback 0 -- lr = 0x210099f4
240e41f4b71Sopenharmony_citraceback 1 -- lr = 0x2101daec
241e41f4b71Sopenharmony_citraceback 2 -- lr = 0x2101db3c
242e41f4b71Sopenharmony_citraceback 3 -- lr = 0x2101c494
243e41f4b71Sopenharmony_ci----- traceback end -----
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci[LMS] Dump info around address [0x2104041c]:
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci        [0x21040398]:  00  00  00  00  00  00  00  00 | [0x21041e7d |  0]:  1  1
248e41f4b71Sopenharmony_ci        [0x210403a0]:  00  00  00  00  00  00  00  00 | [0x21041e7d |  4]:  1  1
249e41f4b71Sopenharmony_ci        [0x210403a8]:  00  00  00  00  00  00  00  00 | [0x21041e7e |  0]:  1  1
250e41f4b71Sopenharmony_ci        [0x210403b0]:  00  00  00  00  00  00  00  00 | [0x21041e7e |  4]:  1  1
251e41f4b71Sopenharmony_ci        [0x210403b8]:  00  00  00  00  00  00  00  00 | [0x21041e7f |  0]:  1  1
252e41f4b71Sopenharmony_ci        [0x210403c0]:  00  00  00  00  00  00  00  00 | [0x21041e7f |  4]:  1  1
253e41f4b71Sopenharmony_ci        [0x210403c8]:  00  00  00  00  00  00  00  00 | [0x21041e80 |  0]:  1  1
254e41f4b71Sopenharmony_ci        [0x210403d0]:  00  00  00  00  00  00  00  00 | [0x21041e80 |  4]:  1  1
255e41f4b71Sopenharmony_ci        [0x210403d8]:  00  00  00  00  00  00  00  00 | [0x21041e81 |  0]:  1  1
256e41f4b71Sopenharmony_ci        [0x210403e0]:  00  00  00  00  00  00  00  00 | [0x21041e81 |  4]:  1  1
257e41f4b71Sopenharmony_ci        [0x210403e8]:  00  00  00  00  00  00  00  00 | [0x21041e82 |  0]:  1  1
258e41f4b71Sopenharmony_ci        [0x210403f0]:  00  00  00  00  00  00  00  00 | [0x21041e82 |  4]:  1  1
259e41f4b71Sopenharmony_ci        [0x210403f8]:  40  1e  04  21  05  07  00  80 | [0x21041e83 |  0]:  2  2
260e41f4b71Sopenharmony_ci        [0x21040400]:  00  00  00  00  00  00  00  00 | [0x21041e83 |  4]:  0  0
261e41f4b71Sopenharmony_ci        [0x21040408]:  00  00  00  00  00  00  00  00 | [0x21041e84 |  0]:  0  0
262e41f4b71Sopenharmony_ci        [0x21040410]:  00  00  00  00  f8  03  04  21 | [0x21041e84 |  4]:  0  2
263e41f4b71Sopenharmony_ci        [0x21040418]:  05  8b  06  00 [00] 00  00  00 | [0x21041e85 |  0]:  2 [3]
264e41f4b71Sopenharmony_ci        [0x21040420]:  00  00  00  00  00  00  00  00 | [0x21041e85 |  4]:  3  3
265e41f4b71Sopenharmony_ci        [0x21040428]:  00  00  00  00  00  00  00  00 | [0x21041e86 |  0]:  3  3
266e41f4b71Sopenharmony_ci        [0x21040430]:  14  04  04  21  00  84  06  00 | [0x21041e86 |  4]:  2  2
267e41f4b71Sopenharmony_ci        [0x21040438]:  00  00  00  00  00  00  00  00 | [0x21041e87 |  0]:  3  3
268e41f4b71Sopenharmony_ci        [0x21040440]:  00  00  00  00  00  00  00  00 | [0x21041e87 |  4]:  3  3
269e41f4b71Sopenharmony_ci        [0x21040448]:  00  00  00  00  00  00  00  00 | [0x21041e88 |  0]:  3  3
270e41f4b71Sopenharmony_ci        [0x21040450]:  00  00  00  00  00  00  00  00 | [0x21041e88 |  4]:  3  3
271e41f4b71Sopenharmony_ci        [0x21040458]:  00  00  00  00  00  00  00  00 | [0x21041e89 |  0]:  3  3
272e41f4b71Sopenharmony_ci        [0x21040460]:  00  00  00  00  00  00  00  00 | [0x21041e89 |  4]:  3  3
273e41f4b71Sopenharmony_ci        [0x21040468]:  00  00  00  00  00  00  00  00 | [0x21041e8a |  0]:  3  3
274e41f4b71Sopenharmony_ci        [0x21040470]:  00  00  00  00  00  00  00  00 | [0x21041e8a |  4]:  3  3
275e41f4b71Sopenharmony_ci        [0x21040478]:  00  00  00  00  00  00  00  00 | [0x21041e8b |  0]:  3  3
276e41f4b71Sopenharmony_ci        [0x21040480]:  00  00  00  00  00  00  00  00 | [0x21041e8b |  4]:  3  3
277e41f4b71Sopenharmony_ci        [0x21040488]:  00  00  00  00  00  00  00  00 | [0x21041e8c |  0]:  3  3
278e41f4b71Sopenharmony_ci        [0x21040490]:  00  00  00  00  00  00  00  00 | [0x21041e8c |  4]:  3  3
279e41f4b71Sopenharmony_ci        [0x21040498]:  00  00  00  00  00  00  00  00 | [0x21041e8d |  0]:  3  3
280e41f4b71Sopenharmony_ci[ERR][TestLmsTsk]*****  Kernel Address Sanitizer Error Detected End *****
281e41f4b71Sopenharmony_cistr[ 0]=0x 0
282e41f4b71Sopenharmony_ci######LmsTestUseAfterFree stop ######
283e41f4b71Sopenharmony_ci```
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ciThe key output information is as follows:
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci- Error type:
288e41f4b71Sopenharmony_ci  - Heap buffer overflow
289e41f4b71Sopenharmony_ci  - UAF
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci- Incorrect operations:
292e41f4b71Sopenharmony_ci  - Illegal read
293e41f4b71Sopenharmony_ci  - Illegal write
294e41f4b71Sopenharmony_ci  - Illegal double free
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci- Context:
297e41f4b71Sopenharmony_ci  - Task information (**taskName** and **taskId**)
298e41f4b71Sopenharmony_ci  - Backtrace
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci- Memory information of the error addresses:
301e41f4b71Sopenharmony_ci  - Memory value and the value of the corresponding shadow memory
302e41f4b71Sopenharmony_ci  - Memory address: memory value|[shadow memory address|shadow memory byte offset]: shadow memory value
303e41f4b71Sopenharmony_ci  - Shadow memory value. **0** (Accessible), **3** (Freed), **2** (RedZone), and **1** (filled value)
304