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

ipc3: check alignment of ext data #9459

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

cujomalainey
Copy link
Member

Sizes are not currently checked for alignment, this can generated unaligned pointers for aligned types which is undefined behaviour.

Sizes are not currently checked for alignment, this can generated
unaligned pointers for aligned types which is undefined behaviour.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
@marc-hb
Copy link
Collaborator

marc-hb commented Sep 11, 2024

I was really wondering how the GCC aligned attribute and extension could result in "undefined behavior" since it is not part of the standard and no undefined behavior is mentioned in the documentation:
https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html

I think the answer is: this is now part of the standard! But under a different name:
https://en.cppreference.com/w/c/language/_Alignas

So the GCC extension has likely been "retrofitted" to behave like the standard alignas - undefined behaviors included?

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix for v2.11, I think we made a mistake using bytes for size in IPC3 when we always use words for size/alignment. Oh well.

@kv2019i kv2019i merged commit 0ab4441 into thesofproject:main Sep 11, 2024
45 of 47 checks passed
@cujomalainey cujomalainey deleted the ubsan branch September 11, 2024 15:06
@cujomalainey
Copy link
Member Author

Whoops, there is an IS_ALIGNED macro, I must have pushed the wrong branch. I'll send a fix today.

@marc-hb
Copy link
Collaborator

marc-hb commented Sep 11, 2024

Whoops, there is an IS_ALIGNED macro, I must have pushed the wrong branch. I'll send a fix today.

Maybe an opportunity to add some "TODOs: switch to the new standard" next to these macro definitions?

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.

4 participants