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 proper alignment of cmsg buffers #234

Merged
merged 1 commit into from Jul 17, 2020

Conversation

jcourreges
Copy link
Contributor

@jcourreges jcourreges commented May 10, 2020

The cmsg macros expect a control message buffer to be aligned like
a struct cmsghdr. The current layout around those stack-allocated
buffers probably provides the required alignment (usually 4 bytes).
Use a union to enforce proper alignment, in case future changes modify
the stack layout.

Spotted when chasing an unrelated bug with Otto Moerbeek (@omoerbeek).

The cmsg macros expect a control message buffer to be aligned like
a struct cmsghdr.  The current layout around those stack-allocated
buffers probably provides the required alignment (usually 4 bytes).
Use a union to enforce proper alignment, in case future changes modify
the stack layout.

Spotted when chasing an unrelated bug with Otto Moerbeek (@omoerbeek).
@ralphdolmans ralphdolmans self-assigned this Jul 13, 2020
@ralphdolmans
Copy link
Contributor

ralphdolmans commented Jul 17, 2020

Thanks. This in need makes sense to do to prevent a potential future issue.

There are some sizeof(control)s left in log_assert statements in comm_point_send_udp_msg_if, these also need to be changed to control.buff. I'll make these changes and merge this.

ralphdolmans added a commit that referenced this pull request Jul 17, 2020
  Courrèges-Anglas.
- Fix PR #234 log_assert sizeof to use union buffer.
@ralphdolmans ralphdolmans merged commit 7d364f1 into NLnetLabs:master Jul 17, 2020
jedisct1 added a commit to jedisct1/unbound that referenced this pull request Jul 27, 2020
* nlnet/master: (30 commits)
  Changelog note for PR NLnetLabs#270 - Merge PR NLnetLabs#270 from cgzones: munin plugin: always exit 0 in autoconf
  - Merge PR NLnetLabs#269, Fix python module len() implementations, by Torbjörn Lönnemark
  - branch now named 1.11.1.  1.11.0rc1 became the 1.11.0 release.
  munin plugin: always exit 0 in autoconf
  Fix python module len() implementations
  draft-ietf-dnsop-serve-stale-10 has become RFC 8767 on March 2020
  - branch now named 1.11.0 and 1.11.0rc1 tag.
  - Fix contrib/fastrpz.patch to apply cleanly.  It fixes for changes   due to added libdynmod, but it does not compile, it conflicts with   new rpz code.
  - Fix contrib/fastrpz.patch to apply cleanly.
  - Fix contrib/fastrpz.patch to apply cleanly.
  - Fix streamtcp to print packet data to stdout.  This makes the   stdout and stderr not mix together lines, when parsing its output.
  - Fix lock dependency cycle in rpz zone config setup.
  - Fix libnettle compile for session ticket key callback function   changes.
  - Merge PR NLnetLabs#234 - Ensure proper alignment of cmsg buffers by Jérémie   Courrèges-Anglas. - Fix PR NLnetLabs#234 log_assert sizeof to use union buffer.
  - Fix unused variable warning for clang analyzer.
  - Fix check conf test for referencing installation paths.
  - Changelog entry for PR NLnetLabs#265; include-toplevel.
  Change unbound-dnstap-socket void cast for unused parameter
  - Add changelog entry for bidirectional frame streams support.
  correct byte count in comment
  ...
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.

None yet

2 participants