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

Ensure correct alignment when dealing with control messages #662

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

smcv
Copy link
Collaborator

@smcv smcv commented Oct 16, 2024

  • utils: Don't assume cmsg data is aligned suitably for struct ucred

    As documented in cmsg(3), the alignment of control messages is not
    guaranteed, so for portability to architectures with strong alignment
    requirements we should memcpy to and from a suitably aligned instance
    of the desired data structure on the stack.

    Helps: bubblewrap misuses CMSG_DATA() macro #637

  • utils: Ensure that the buffer for struct cmsghdr is suitably-aligned

    A char array on the stack is not guaranteed to have any particular
    alignment.

    Resolves: bubblewrap misuses CMSG_DATA() macro #637

cc @mcatanzaro @refi64

@smcv smcv added the bug label Oct 16, 2024
@smcv smcv self-assigned this Oct 16, 2024
utils.c Outdated Show resolved Hide resolved
As documented in cmsg(3), the alignment of control messages is not
guaranteed, so for portability to architectures with strong alignment
requirements we should memcpy to and from a suitably aligned instance
of the desired data structure on the stack.

Helps: containers#637
Signed-off-by: Simon McVittie <smcv@collabora.com>
A char array on the stack is not guaranteed to have any particular
alignment.

Resolves: containers#637
Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv smcv merged commit 0545e72 into containers:main Oct 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bubblewrap misuses CMSG_DATA() macro
2 participants