Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/mesh/ip_internal_network: misconfiguration of driver_ifconfig.driver_free_rx_buffer (IDFGH-13310) #14235

Open
3 tasks done
vjgriswold opened this issue Jul 23, 2024 · 2 comments
Assignees
Labels
Status: Reviewing Issue is being reviewed

Comments

@vjgriswold
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

In mesh_netif.c,
functions mesh_driver_start_root_ap() and mesh_driver_start_node_sta(), the callback function driver_free_rx_buffer is initialized to the function mesh_free() which, in turn, forwards all calls to the heap-based free().

The actual ESP-WIFI-MESH esp_netif initialization configures the driver_free_rx_buffer callback to the function wifi_free() in wifi_netif.c. This correct function forwards all calls to esp_wifi_internal_free_rx_buffer().

It therefore appears highly likely that buffer-free operations may release Rx buffers onto the wrong free-list, corrupting the WiFi buffer-management facility.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 23, 2024
@github-actions github-actions bot changed the title examples/mesh/ip_internal_network: misconfiguration of driver_ifconfig.driver_free_rx_buffer examples/mesh/ip_internal_network: misconfiguration of driver_ifconfig.driver_free_rx_buffer (IDFGH-13310) Jul 23, 2024
@zhangyanjiaoesp
Copy link
Collaborator

@vjgriswold Thanks for report, we will check it ASAP.

@zhangyanjiaoesp
Copy link
Collaborator

@vjgriswold
If the netif uses the standard wifi driver, when receiving a packet, the path is this:

sta_input(eb) 
-> esp_netif_receive(netif, buffer, len, eb) 
-> esp_netif->lwip_input_fn(netif, buffer, len, eb) 
-> wlanif_input(netif, buffer, len, l2_buff) 
-> esp_netif_free_rx_buffer(netif, l2_buff) 
-> wifi_free(l2_buff) 
-> esp_wifi_internal_free_rx_buffer(l2_buff)

the l2_buff is the eb used in the wifi driver, so free it in the wifi layer is correct.

If the netif uses the mesh link driver, when receiving a packet, the path is this:

sta_input(eb) 
-> mesh_task, convert the wifi eb into a mesh-type packet and release the eb 
-> receive_task() 
-> esp_netif_receive(netif, data.data, data.len, NULL) 
->esp_netif->lwip_input_fn(netif, buffer, len, l2_buff) 
-> wlanif_input(netif, buffer, len, l2_buff) 
-> esp_netif_free_rx_buffer(netif, l2_buff) 
-> mesh_free(l2_buff)
-> free(l2_buff)

the l2_buff is NULL, so free it using heap-based free() is correct.

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewing Issue is being reviewed
Projects
None yet
Development

No branches or pull requests

3 participants