Skip to content

net: icmp: assert triggered sending icmp echo response with CONFIG_NET_STATISTICS=y #107920

Closed

Description

@tpambor

Describe the bug

An assertion is triggered in

{ NET_ASSERT(_iface); (UPDATE_STAT_GLOBAL(_cmd)); \
when sending an ICMP echo response if CONFIG_NET_STATISTICS is enabled. The crash occurs because the code attempts to access the interface (iface) from a packet pointer that has already been freed.

The issue occurs in the following logic:

  1. An ICMP echo response is generated.
  2. The packet (reply) is processed and subsequently freed by the network stack after net_try_send_data().
  3. The statistics update function is called: net_stats_update_icmp_sent(net_pkt_iface(reply)).
  4. Since reply is already freed, net_pkt_iface(reply) returns NULL.

Regression

  • This is a regression.

Steps to reproduce

  1. CONFIG_NET_STATISTICS=y + CONFIG_ASSERT=y
  2. Send ICMP requests
  3. Observe assertion

Relevant log output

Impact

Functional Limitation – Some features not working as expected, but system usable.

Environment

  • OS: Linux
  • Toolchain: Zephyr SDK 1.0.1
  • Version: 4.4.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions