sctp: fix outgoing SACK corruption on DATA chunk reception - #271
Open
r-c-n wants to merge 1 commit into
Open
Conversation
On libpeer's own SCTP implementation, reception of a DATA chunk may result in a call to the "onmessage" callback, if available. Before running the callback, sctp_incoming_data() prepares a SACK chunk that is meant to be sent after the callback is done, but if the callback sends any data as a response, it'll overwrite the already formatted SACK chunk header, corrupting the SACK. Fix it by sending moving the SACK send before the callback. Signed-off-by: Ricardo Cañuelo Navarro <rcn@igalia.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On libpeer's own SCTP implementation, reception of a DATA chunk may result in a call to the
onmessagecallback, if available. Before running the callback, sctp_incoming_data() prepares a SACK chunk that is meant to be sent after the callback is done, but if the callback sends any data as a response, it'll overwrite the already formatted SACK chunk header, corrupting the SACK.Fix it by moving the SACK send before the callback.
NOTE: similar problems may surface depending on what the
onmessage,onopenandonclosedo. I've only seen this happening in theSCTP_DATAcase but I think it could also happen in theSCTP_COOKIE_ECHOcase. I haven't tested it, though, so any opinion is appreciated.Example
Before the fix, if the peer receives a DATA chunk, it first sends another DATA chunk as a response (similar to what
libpeer/examples/pico/main.c
Line 34 in 9319aa4
After the fix, on the same interchange, the peer sends the SACK first, then runs the
onmessagecallback to send the DATA chunk: