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

src: Fix genl command payload size calculations. #269

Merged
merged 2 commits into from
Nov 4, 2022

Conversation

ossama-othman
Copy link
Member

Correct generic netlink command payload buffer size calculations by aligning against the size of the attribute (e.g. sizeof(uint16_t)) as expected instead of size of the attribute size (e.g. sizeof(sizeof(uint16_t))).

Payload buffer sizes should now be smaller in some cases since netlink attributes are aligned on a 4 byte boundary. For example, the underlying NLA_ALIGN() macro returns 4 when the type is uint16_t, i.e. NLA_ALIGN(sizeof(uint16_t)). Previously, 8 was returned on 64 bit platforms since the NLA_ALIGN() call was incorrectly called as NLA_ALIGN(sizeof(sizeof(uint16_t))), which boils downs to NLA_ALIGN(size_t).

Ossama Othman added 2 commits November 3, 2022 13:06
The user supplied local port isn't used in the "add subflow" command
but it is still sent to the kernel if it is non-zero.  Make sure there
is enough room for it in the payload.
Correct generic netlink command payload buffer size calculations by
aligning against the size of the attribute (e.g. sizeof(uint16_t)) as
expected instead of size of the attribute size
(e.g. sizeof(sizeof(uint16_t))).

Payload buffer sizes should be smaller in some cases since netlink
attributes are aligned on a 4 byte boundary.  For example, the
underlying NLA_ALIGN() macro returns 4 when the type is uint16_t,
i.e. NLA_ALIGN(sizeof(uint16_t)).  Previously, 8 was returned on 64
bit platforms since the NLA_ALIGN() call was incorrectly called like as
NLA_ALIGN(sizeof(sizeof(uint16_t))), which boils downs to
NLA_ALIGN(size_t).
@ossama-othman ossama-othman added the bug Something isn't working label Nov 4, 2022
@ossama-othman ossama-othman self-assigned this Nov 4, 2022
@coveralls
Copy link

coveralls commented Nov 4, 2022

Pull Request Test Coverage Report for Build 3390929654

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 51 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 65.005%

Files with Coverage Reduction New Missed Lines %
src/netlink_pm_upstream.c 51 73.16%
Totals Coverage Status
Change from base Build 3086411145: 0.03%
Covered Lines: 1395
Relevant Lines: 2146

💛 - Coveralls

@ossama-othman ossama-othman merged commit ccc7782 into multipath-tcp:master Nov 4, 2022
@ossama-othman ossama-othman deleted the fix-payload-sizes branch November 4, 2022 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants