Part Number: CC2530
I got the following memory access error during the execution of the gateway:
[2020-11-02 18:00:05.930,116] [GATEWAY/HNDL] MISC1 : Processing Af Incoming Message Indication [2020-11-02 18:00:05] ================================================================= [2020-11-02 18:00:05] ==16502==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb5a06734 at pc 0x0010e5c9 bp 0xb5b68b38 sp 0xb5b68b3c [2020-11-02 18:00:05] WRITE of size 2 at 0xb5a06734 thread T2 [2020-11-02 18:00:05] #0 0x10e5c7 in zclParseInWriteRspCmd ../../../../Components/stack/zcl/zcl.c:3568 [2020-11-02 18:00:05] #1 0x108189 in zcl_ProcessMessageMSG ../../../../Components/stack/zcl/zcl.c:2044 [2020-11-02 18:00:06] #2 0x640b9 in processAfIncomingMsgInd .../3rdparty/ti/Zigbee_3_0_Linux_Gateway_1_0_1/source/Projects/zstack/linux/hagateway/gatewaysrvr.c:5769 [2020-11-02 18:00:06] #3 0x52897 in handleAsyncMsgs .../3rdparty/ti/Zigbee_3_0_Linux_Gateway_1_0_1/source/Projects/zstack/linux/hagateway/gatewaysrvr.c:1111 [2020-11-02 18:00:06] #4 0xb8873 in asynchMsgCback ../srvwrapper/api_client.c:1372 [2020-11-02 18:00:06] #5 0xb8181 in SIShandleThreadFunc ../srvwrapper/api_client.c:1296 [2020-11-02 18:00:06] [2020-11-02 18:00:06] 0xb5a06735 is located 0 bytes to the right of 5-byte region [0xb5a06730,0xb5a06735) [2020-11-02 18:00:06] allocated by thread T2 here: [2020-11-02 18:00:06] #0 0x19943b in __interceptor_malloc /home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/snapshots/gcc-linaro-5. [2020-11-02 18:00:06] [2020-11-02 18:00:06] Thread T2 created by T0 here: [2020-11-02 18:00:06] #0 0x156a1b in __interceptor_pthread_create /home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/snapshots/gcc-l [2020-11-02 18:00:06] #1 0xb5803ebf (<unknown module>) [2020-11-02 18:00:06] [2020-11-02 18:00:06] SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../Components/stack/zcl/zcl.c:3568 zclParseInWriteRspCmd [2020-11-02 18:00:06] Shadow bytes around the buggy address: [2020-11-02 18:00:06] 0x36b40c90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40ca0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40cb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40cc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40cd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] =>0x36b40ce0: fa fa fa fa fa fa[05]fa fa fa 00 07 fa fa 06 fa [2020-11-02 18:00:06] 0x36b40cf0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd [2020-11-02 18:00:06] 0x36b40d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40d10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40d20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] 0x36b40d30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa [2020-11-02 18:00:06] Shadow byte legend (one shadow byte represents 8 application bytes): [2020-11-02 18:00:06] Addressable: 00 [2020-11-02 18:00:06] Partially addressable: 01 02 03 04 05 06 07 [2020-11-02 18:00:06] Heap left redzone: fa [2020-11-02 18:00:06] Heap right redzone: fb
The access error happened on the highlighted line:
static void *zclParseInWriteRspCmd( zclParseCmd_t *pCmd )
{
zclWriteRspCmd_t *writeRspCmd;
uint8 *pBuf = pCmd->pData;
uint8 i = 0;
writeRspCmd = (zclWriteRspCmd_t *)zcl_mem_alloc( sizeof ( zclWriteRspCmd_t ) + pCmd->dataLen );
if ( writeRspCmd != NULL )
{
if ( pCmd->dataLen == 1 )
{
// special case when all writes were successfull
writeRspCmd->attrList[i++].status = *pBuf;
}
else
{
while ( pBuf < ( pCmd->pData + pCmd->dataLen ) )
{
writeRspCmd->attrList[i].status = *pBuf++;
writeRspCmd->attrList[i++].attrID = BUILD_UINT16( pBuf[0], pBuf[1] );
pBuf += 2;
}
}
writeRspCmd->numAttr = i;
}
return ( (void *)writeRspCmd );
}
This happened when an attribute could not be written (sniffer log extract):
ZigBee Cluster Library Frame, Command: Write Attributes Response, Seq: 0
Frame Control Field: Profile-wide (0x08)
.... ..00 = Frame Type: Profile-wide (0x0)
.... .0.. = Manufacturer Specific: False
.... 1... = Direction: Server to Client
...0 .... = Disable Default Response: False
Sequence Number: 0
Command: Write Attributes Response (0x04)
Status Record
Status: Invalid Value (0x87)
Attribute: OccupiedHeatingSetpoint (0x0012)