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

[stable-v2.12] zephyr: fix overflow and overlap checks in memcpy_s #9771

Conversation

kv2019i
Copy link
Collaborator

@kv2019i kv2019i commented Jan 9, 2025

This patch addresses an issue in the memcpy_s function within the Zephyr RTOS string header. The issue was identified during IPC3 fuzz testing with UndefinedBehaviorSanitizer enabled.

Changes include:

  • Adding stdint.h for uintptr_t type.
  • Adding checks to prevent overflow in pointer arithmetic.
  • Adjusting overlap checks to avoid overflow.

These changes ensure that the memcpy_s function correctly handles edge cases, preventing undefined behavior due to pointer arithmetic overflow and memory overlap.

Fixes #9768

(cherry picked from commit 7d11802)

This patch addresses an issue in the `memcpy_s` function within the
Zephyr RTOS string header. The issue was identified during IPC3 fuzz
testing with UndefinedBehaviorSanitizer enabled.

Changes include:
- Adding `stdint.h` for `uintptr_t` type.
- Adding checks to prevent overflow in pointer arithmetic.
- Adjusting overlap checks to avoid overflow.

These changes ensure that the `memcpy_s` function correctly handles edge
cases, preventing undefined behavior due to pointer arithmetic overflow
and memory overlap.

Fixes thesofproject#9768

Signed-off-by: Tomasz Leman <[email protected]>
(cherry picked from commit 7d11802)
Signed-off-by: Kai Vehmanen <[email protected]>
@kv2019i
Copy link
Collaborator Author

kv2019i commented Jan 9, 2025

FYI @lyakh @cgturner1 interesting in stable-v2.12 branch the github flows pass without space issues, so it must be some recent change in SOF main that has caused the space requirements to jump up.

@kv2019i kv2019i merged commit 2d9853e into thesofproject:stable-v2.12 Jan 9, 2025
44 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants