Skip to content

Ensure proper alignment of cmsg buffers - #234

Merged
ralphdolmans merged 1 commit into
NLnetLabs:masterfrom
jcourreges:align-cmsg-buffers
Jul 17, 2020
Merged

Ensure proper alignment of cmsg buffers#234
ralphdolmans merged 1 commit into
NLnetLabs:masterfrom
jcourreges:align-cmsg-buffers

Conversation

@jcourreges

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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.

2 participants