Illegal memory access occurs when resending telemetry data when NXD_MQTT_OVER_WEBSOCKET is enabled

yoji sato 281 Reputation points
2023-06-06T06:55:01.3466667+00:00
Currently, we are developing a system that operates by connecting to IoTHUB using AzureRTOS on RX65N.
Since the system requires access via a proxy server, We are using NXD_MQTT_OVER_WEBSOCKET enabled.

When the system is transmitting telemetry data, 
We are facing the problem of bus errors when TCP retransmissions occur for some reason.

We used the debugger to track down where the bus error occurred and found
_nx_tcp_socket_retransmit() uses nx_packet_prepend_ptr in packet_ptr, but it seems that 
the value is inappropriate for telemetry data, and that's why a bus error occurs.

Upon further investigation of this case,
The area for telemetry data is acquired with nx_azure_iot_publish_packet_get(), 
but the function used for acquisition there is nx_secure_tls_packet_allocate() 
and it seems that the area for web sockets is not considered. is.

So, try nx_websocket_client_packet_allocate() for web socket
After confirming the operation after modifying it to secure the area using it, 
it seems that it works well without a bus error even if a retransmission operation occurs.


The following 3 items are requested for confirmation.

(1) Has Microsoft confirmed any of the following problems?
    When sending telemetry data with NXD_MQTT_OVER_WEBSOCKET enabled, access to an invalid memory 
    address occurs when TCP retransmission occurs for some reason.

(2) Is the following a good solution for this problem?
    Change function used in nx_azure_iot_publish_packet_get() from nx_secure_tls_packet_allocate() 
    to nx_websocket_client_packet_allocate() when NXD_MQTT_OVER_WEBSOCKET is enabled
    (attaching the file of the correction example)

(3) Could you please consider confirming the reproduction of this issue at Microsoft and providing 
    a countermeasure version?


Best regards, 

---
Yoji Sato
Grape Systems Inc.

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
330 questions
{count} votes

Accepted answer
  1. Haiqing Zhao 165 Reputation points Microsoft Employee
    2023-06-08T01:52:48.9433333+00:00

    Hello @yoji sato , could you please let me know whether the macro NX_DISABLE_IPV6 is defined in your system, thanks a lot.

    Update

    We have identified this as an issue and a fix will be rolled out on GitHub to address this by the end of the month.

    Work around

    Before the official patch is released, to remediate any business impact, you could try with the patch 0001-Fix-illegal-access-when-NXD_MQTT_OVER.txt. Since .patch extension is not allowed as an attachment, I changed it to .txt extension and you may change it back after downloading and apply the patch.

    In the future, the official fix can be accessed in Github by the end of this month, and the official release which includes this fix is planned in October this year.

    Fix

    The official fix can be accessed through Github in the commit on 30 June, 2023, through https://github.com/azure-rtos/netxduo/commit/b53390f94b6f7655059b6a3763c3a016ed61681

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful