-
Notifications
You must be signed in to change notification settings - Fork 2k
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
gnrc_pktbuf_static: fix alignment issue / leaks #9434
Merged
cgundogan
merged 3 commits into
RIOT-OS:master
from
miri64:gnrc_pktbuf_static/fix/alignment-race
Jul 2, 2018
Merged
gnrc_pktbuf_static: fix alignment issue / leaks #9434
cgundogan
merged 3 commits into
RIOT-OS:master
from
miri64:gnrc_pktbuf_static/fix/alignment-race
Jul 2, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes an alignment issue I encountered in the static version of the packet buffer. The bug is caused by a race-condition where a certain order of operations leads to a chunk being released according to the byte-alignment of the platform, but overlapping potential space for a future `_unused_t` struct e.g. (x mark allocated regions): Future leak of size sizeof(_unused_t) Time v | +------------+-----+--------------------+ | |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| + +------------+-----+--------------------+ | | +------------+--+--+--------------------+ | | |xxxxxxxxxxxxxxxxxxxxxxx| + +------------+--+--+--------------------+ | | +-----+------+--+--+--------------------+ | |xxxxx| |xxxxxxxxxxxxxxxxxxxxxxx| + +-----+------+--+--+--------------------+ | | +-----+------+-----+---------+----------+ | |xxxxx| |xxxxxxxxxx| + +-----+------+-----+---------+----------+ | | +-----+------+-----+--------------------+ | |xxxxx| |xxxxxxxxxxxxxxxxxxxxxxxxxx| + +-----+------+-----+--------------------+ | | +------------+-----+--------------------+ | |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| + +------------+-----+--------------------+ | | +------------+-----+--------------------+ | |xxxxxxxxxxxxxxxxxx| | + +------------+-----+--------------------+ | | +------------+-----+--------------------+ | | |xxxxx| | + +------------+-----+--------------------+ | v Sadly, I wasn't able to create a reproducable unittest that show-cases this corner-case, since I don't understand the order of operations that cause this one 100%, but the bug is reproducable (but also not reliably) by sending large (i.e. fragmented) packets to a 6Lo-enabled host from more than 1 host simultaneously (use `gnrc_pktbuf_cmd` to check). By making the size of `_unused_t` the only condition for alignment, this bug is fixed.
miri64
added
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Area: network
Area: Networking
GNRC
labels
Jun 27, 2018
cgundogan
approved these changes
Jul 2, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately I couldn't reproduce, but the change is sensible and doesn't break the current behavior. ACK
cgundogan
added
the
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
label
Jul 2, 2018
tested on the iotlab-testbed using three iotlab-m3 nodes in the paris site. Can confirm the leak pre-PR and the fix post-PR. ACK and GO. |
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: network
Area: Networking
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
This fixes an alignment issue I encountered in the static version of the packet buffer.
The bug is caused by a race-condition where a certain order of operations leads to a chunk being released according to the byte-alignment of the platform, but overlapping potential space for a future
_unused_t
struct e.g. (x mark allocated regions):Sadly, I wasn't able to create a reproducable unittest that show-cases this corner-case, since I don't understand the order of operations that cause this one 100%, but the bug is reproducable (but also not
reliably) by sending large (i.e. fragmented) packets to a 6Lo-enabled host from more than 1 host simultaneously (use
gnrc_pktbuf_cmd
to check but don't confuse incomplete datagrams for leaks; see #9424 for faster clean-up of those). I ran this test twice for an hour with this PR before submitting, to make sure this fixes the issue.By making the size of
_unused_t
the only condition for alignment, this bug is fixed.This PR also contains some optimizations that can be done due to the new alignment (acfe57a)
Issues/PRs references
#9424 can simplify testing a bit