fix: prevent panic when creating flows from malformed linux sll packets#139
Merged
mosajjal merged 1 commit intogopacket:masterfrom Nov 2, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a panic in LinuxSLL and LinuxSLL2 layers when processing malformed packets with hardware addresses exceeding 16 bytes (MaxEndpointSize). The fix truncates oversized addresses before creating flows, preventing crashes while maintaining backward compatibility.
Key Changes:
- Modified
LinkFlow()methods in bothLinuxSLLandLinuxSLL2to truncate addresses exceedingMaxEndpointSize - Added comprehensive unit tests to verify truncation behavior for various address sizes
- Included an example program demonstrating the fix with test pcap data
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
layers/linux_sll.go |
Added address length validation and truncation logic in LinkFlow() method |
layers/linux_sll2.go |
Added address length validation and truncation logic in LinkFlow() method |
layers/linux_sll_oversized_test.go |
Added unit tests for both LinuxSLL and LinuxSLL2 truncation behavior |
examples/linux_sll_test/main.go |
Added example program to demonstrate fix with pcap processing |
examples/linux_sll_test/README.md |
Added documentation for the example program |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fix: Linux SLL/SLL2 Panic on Oversized Addresses
Summary
Fixed a panic in
LinuxSLLandLinuxSLL2layers that occurred when processing packets with hardware addresses exceedingMaxEndpointSize(16 bytes).Problem
The
LinkFlow()method in bothLinuxSLLandLinuxSLL2layers was passing the raw hardware address directly togopacket.NewFlow()without validating its length. When a packet contained an address larger thanMaxEndpointSize(16 bytes), this caused a panic:Root Cause
gopacket.NewFlow()uses fixed-size byte arrays for performance and requires addresses ≤ 16 bytesReproduction
A test pcap file that reproduces this issue is included:
layers/testdata/linux_sll_oversized_addr.pcapngStack Trace (Anonymized)
Solution
Modified
LinkFlow()methods in both layers to truncate oversized addresses toMaxEndpointSizebefore creating flows. This approach:Changes
File:
layers/linux_sll.goFile:
layers/linux_sll2.goTesting
To verify the fix:
Verify no panics occur and processing completes successfully
Impact