-
Notifications
You must be signed in to change notification settings - Fork 896
slow: Add OSSP support #1363
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
Open
corubba
wants to merge
2
commits into
the-tcpdump-group:master
Choose a base branch
from
corubba:feature/slow-ossp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−1
Open
slow: Add OSSP support #1363
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
1 2025-09-23 15:00:00.000000 OSSP, length 52 | ||
OUI: ITU-T (0x0019a7) | ||
0x0000: 0001 1000 0000 0100 0404 0000 0000 0000 | ||
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 | ||
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 |
Binary file not shown.
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.
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.
As far as I can see, this line can cause an out-of-bounds read: neither
slow_ossp_print()
nor its caller ensure that heretlen >= 3
. Please add a length check.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.
GET_BE_U_3
does a length check, and will not return if there is not enough data. You can find the same pattern in other protocols, for example here, here and here. Worked fine when I tested it reducing the packet step by step one byte at a time.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.
In this context the
GET_
macros guard the boundaries of the actually present (captured) data, andtlen
is the declared data length. Please note:ND_ICHECK_U(len, <, 8);
just before the data fetch in the first example,if (subtlv_len >= 6)
around the data fetch in the second example, andif (len < length * NSH_HDR_WORD_SIZE)
before the data fetch in the third example.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.
I don't really understand how
tlen
could ever be less than the captured data (the other way around sure), and thustlen < 3
not always first trigger theGET_BE_U_3
longjump. But I will assume you know better and submit to your judgement.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.
I guess the reason is to have the correct message in the output, truncated packet (due to snaplen) vs invalid packet (simply too short).
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.
Correctness of reporting is one reason, and consistency of code style is another.
Yet another reason is safety: any "length" recorded in the captured data generally cannot be trusted. In this case
tlen
is not obviously off: the EtherType/length field of the Ethernet frame stands for EtherType so inethertype_print()
it seems likely thatlength >= caplen
, especially when the frame is read from a file and the length values have been sanitized.However, if you consider how many protocols encapsulate Ethernet frames now and how many more will do that in future, it is almost certain that an encoding exists that has its own idea of an encapsulated Ethernet frame length and will present, let's say, 1KB of "captured" data and a value of length that will cause
tlen
here to be, let's say, 1. Then after the subtractiontlen
would underflow to a very large value andprint_unknown_data()
will be printing a memory dump until it trips a boundary of the process' virtual memory and causes a segmentation fault. This is why the other three cases in this file and most if not all other decoders check both lengths.