Skip to content

Fix undefined behavior reported by UBSAN in network subsystem #90882

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

Open
1 task
tpambor opened this issue May 30, 2025 · 0 comments
Open
1 task

Fix undefined behavior reported by UBSAN in network subsystem #90882

tpambor opened this issue May 30, 2025 · 0 comments
Assignees
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@tpambor
Copy link
Contributor

tpambor commented May 30, 2025

Describe the bug

This issue serves as a tracking issue for identifying and resolving errors reported by the Undefined Behavior Sanitizer (UBSAN) within the network subsystem. The ultimate goal is to enable UBSAN checks in the CI pipeline once all undefined behavior issues in Zephyr have been addressed.

For additional context and background, see: #88687

Regression

  • This is a regression.

Steps to reproduce

  1. Run tests for network subsystem with undefined behavior sanitizer (UBSAN) enabled, e.g.
    ./scripts/twister -T tests/net/ -p native_sim --enable-ubsan

Relevant log output

zephyr/include/zephyr/net/net_ip.h:1151:9: runtime error: member access within misaligned address 0x080b105e for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:1151:9: runtime error: member access within misaligned address 0x080c869a for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:1151:9: runtime error: member access within misaligned address 0x080e4106 for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:1151:9: runtime error: member access within misaligned address 0x080e5646 for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080a6a9e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080a961e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080aaffe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080aaffe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab21e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab21e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab21e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab23e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab25e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab2fe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab31e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab3fe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab43e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab47e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab47e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab47e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab4fe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab51e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab5fe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab61e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab67e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab67e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab67e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab6fe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab71e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab73e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab73e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab73e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab81e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab81e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080ab81e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080aba1e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080aba1e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080aba1e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abb7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abb7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abb7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abbfe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abbfe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abbfe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abc5e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abd9e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abd9e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abd9e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abefe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abefe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abefe for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abf7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abf7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:685:9: runtime error: member access within misaligned address 0x080abf7e for type 'struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:700:22: runtime error: member access within misaligned address 0x080c8aca for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:700:22: runtime error: member access within misaligned address 0x080c8aea for type 'const struct in6_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:817:22: runtime error: member access within misaligned address 0x080be4ce for type 'struct in_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:817:22: runtime error: member access within misaligned address 0x080cb8de for type 'struct in_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:930:9: runtime error: member access within misaligned address 0x0809e3ce for type 'const struct in_addr', which requires 4 byte alignment
zephyr/include/zephyr/net/net_ip.h:930:9: runtime error: member access within misaligned address 0x0809e3ce for type 'const struct in_addr', which requires 4 byte alignment
zephyr/lib/os/zvfs/zvfs_select.c:70:2: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
zephyr/lib/os/zvfs/zvfs_select.c:70:2: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
zephyr/subsys/net/ip/6lo.c:131:49: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/6lo.c:131:49: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/6lo.c:131:49: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/6lo.c:131:49: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/net_pkt.c:1946:17: runtime error: left shift of 204 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/net_pkt.c:1946:17: runtime error: left shift of 204 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/net_pkt.c:1946:17: runtime error: left shift of 204 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/net_pkt.c:1946:17: runtime error: left shift of 204 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/ip/utils.c:179:5: runtime error: member access within misaligned address 0xf42fa232 for type 'struct in6_addr', which requires 4 byte alignment
zephyr/subsys/net/ip/utils.c:179:5: runtime error: member access within misaligned address 0xf42fa232 for type 'struct in6_addr', which requires 4 byte alignment
zephyr/subsys/net/ip/utils.c:179:5: runtime error: member access within misaligned address 0xf49fb232 for type 'struct in6_addr', which requires 4 byte alignment
zephyr/subsys/net/ip/utils.c:802:8: runtime error: member access within misaligned address 0xf69ff1c6 for type 'struct sockaddr_in6', which requires 4 byte alignment
zephyr/subsys/net/ip/utils.c:802:8: runtime error: member access within misaligned address 0xf6aff1c6 for type 'struct sockaddr_in6', which requires 4 byte alignment
zephyr/subsys/net/ip/utils.c:893:8: runtime error: member access within misaligned address 0xf4afb25a for type 'struct sockaddr_in', which requires 4 byte alignment
zephyr/subsys/net/l2/virtual/ipip/ipip.c:277:34: runtime error: member access within misaligned address 0x080d1a26 for type 'struct sockaddr_in', which requires 4 byte alignment
zephyr/subsys/net/l2/virtual/ipip/ipip.c:277:34: runtime error: member access within misaligned address 0x080d1a26 for type 'struct sockaddr_in', which requires 4 byte alignment
zephyr/subsys/net/l2/virtual/ipip/ipip.c:282:35: runtime error: member access within misaligned address 0x080d1a26 for type 'struct sockaddr_in6', which requires 4 byte alignment
zephyr/subsys/net/l2/virtual/ipip/ipip.c:282:35: runtime error: member access within misaligned address 0x080d1a26 for type 'struct sockaddr_in6', which requires 4 byte alignment
zephyr/subsys/net/lib/coap/coap.c:1500:38: runtime error: left shift of negative value -1
zephyr/subsys/net/lib/dns/dns_sd.c:894:12: runtime error: left shift of 148 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/lib/lwm2m/lwm2m_registry.c:603:6: runtime error: null pointer passed as argument 2, which is declared to never be null
zephyr/subsys/net/lib/lwm2m/lwm2m_registry.c:603:6: runtime error: null pointer passed as argument 2, which is declared to never be null
zephyr/subsys/net/lib/lwm2m/lwm2m_rw_json.c:666:25: runtime error: signed integer overflow: 9223372036854775800 + 8 cannot be represented in type 'long long int'
zephyr/subsys/net/lib/lwm2m/lwm2m_rw_oma_tlv.c:613:12: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
zephyr/subsys/net/lib/lwm2m/lwm2m_rw_plain_text.c:203:25: runtime error: signed integer overflow: 9223372036854775800 + 8 cannot be represented in type 'long long int'
zephyr/subsys/net/lib/lwm2m/lwm2m_rw_senml_cbor.c:648:2: runtime error: null pointer passed as argument 2, which is declared to never be null
zephyr/subsys/tracing/ctf/ctf_top.c:436:9: runtime error: member access within misaligned address 0xf4afb2e2 for type 'struct sockaddr_in', which requires 4 byte alignment
zephyr/tests/net/iface/src/main.c:239:34: runtime error: load of value 11, which is not a valid value for type '_Bool'
zephyr/tests/net/lib/dns_sd/src/main.c:444:24: runtime error: left shift of 177 by 24 places cannot be represented in type 'int'
zephyr/tests/net/lib/dns_sd/src/main.c:444:24: runtime error: left shift of 177 by 24 places cannot be represented in type 'int'
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null
zephyr/tests/net/socket/udp/src/main.c:1498:2: runtime error: null pointer passed as argument 1, which is declared to never be null

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants