Unaligned 32-bit reads following casts on dns_socket_dispatcher::local_addr (Cortex-M0) #77188
Labels
area: Networking
bug
The issue is a bug, or the PR is fixing a bug
platform: Raspberry Pi Pico
Raspberry Pi Pico (RPi Pico)
priority: low
Low impact/importance bug
Describe the bug
dns_socket_dispatcher::local_addr is not aligned for the 32-bit read of
local_addr.sin_addr.s_addr
in net_context_bind() leading to a hard-fault on a Cortex-M0. I've noticed this for the IPv4 path, but I suspect this impacts other paths innet_context_bind()
as well.I've been able to get around with either of the two workarounds:
(a) Forcing the alignment of dns_socket_dispatcher::local_addr to the maximum alignment of the various address types resolves the issue.
(b) Updating net_context_bind() to use the unaligned helpers from net_ip.h.
To Reproduce
Apologies, I'm fairly new and not sure if there's a way to reproduce this in QEMU, so the following assumes access to the physical hardware.
Add the board files from Additional context below to
samples/net/dhcpv4_client/boards
.Set a breakpoint for the faulting instruction:
The following
ldr
tries to perform an unaligned read from address0x200015E2
leading to the hard-fault shown below:Expected behavior
No hard faults in DNS path.
Impact
Unable to use DNS (and DHCP) on my board.
Logs and console output
Environment:
Additional context
boards/rpi_pico.conf
boards/rpi_pico.overlay
The text was updated successfully, but these errors were encountered: