Skip to content

Conversation

@hulryung
Copy link
Contributor

@hulryung hulryung commented Aug 22, 2024

This commit addresses an issue in net_context_bind() where unaligned memory access was not properly handled when checking for INADDR_ANY. The problem primarily affected MCUs like ARMv6 that don't support unaligned memory access.

  • Use UNALIGNED_GET() to safely access the sin_addr.s_addr field
  • Ensures correct behavior on architectures with alignment restrictions

This fix improves compatibility and prevents potential crashes or unexpected behavior on affected platforms.

Fixes #77188

@zephyrbot zephyrbot added area: Networking size: XS A PR changing only a single line of code labels Aug 22, 2024
@github-actions
Copy link

Hello @hulryung, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@jukkar
Copy link
Member

jukkar commented Aug 22, 2024

This commit addresses an issue in net_context_bind() where unaligned
memory access was not properly handled when checking for INADDR_ANY.
The problem primarily affected MCUs like ARMv6 that don't support
unaligned memory access.

- Use UNALIGNED_GET() to safely access the sin_addr.s_addr field
- Ensures correct behavior on architectures with alignment restrictions

This fix improves compatibility and prevents potential crashes or
unexpected behavior on affected platforms.

Signed-off-by: Daekeun Kang <dkkang@huconn.com>
@hulryung
Copy link
Contributor Author

@jukkar, I have reviewed and corrected the compliance issue as you requested.

@carlescufi carlescufi merged commit b24c520 into zephyrproject-rtos:main Aug 26, 2024
@github-actions
Copy link

Hi @hulryung!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

@drensber
Copy link
Contributor

I'm wondering why this isn't labeled to be back ported to 3.7? It's a pretty serious issue on the Raspberry Pi Pico, because it causes a fatal exception in any build that includes DNS. I would assume that the same is true of /any/ board containing a RP2040. I think it's theoretically an issue 3.6 and previous releases too (I think I'd always just been lucky that the structure was already aligned).

@jukkar
Copy link
Member

jukkar commented Oct 1, 2024

Good point, the labeling was just forgotten. I can submit a backport PR manually, I think the backport bot will not do anything if labeling the PR now.
Edit: actually the bot did its thing 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking backport v3.7-branch Request backport to the v3.7-branch size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unaligned 32-bit reads following casts on dns_socket_dispatcher::local_addr (Cortex-M0)

7 participants