l2: fix null pointer access in l2-efp-filter#87
Closed
yelenaRad wants to merge 1 commit intovpp-dev:masterfrom
Closed
l2: fix null pointer access in l2-efp-filter#87yelenaRad wants to merge 1 commit intovpp-dev:masterfrom
yelenaRad wants to merge 1 commit intovpp-dev:masterfrom
Conversation
|
Thank you so much for your interest! VPP takes patches at https://gerrit.fd.io/ |
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.
Problem:
VPP may crash in l2-efp-filter with a SIGSEGV (faulting address 0x0) in the post-rewrite EFP filter path.
Observed backtrace example:
received signal SIGSEGV ... faulting address 0x0
#0 l2_efp_filter_node_fn_hsw ... (libvnet.so.25.10)
#1 vlib_main ...
Root Cause:
Two unsafe assumptions in the post-rewrite EFP filter processing:
extract_keys() always reads h0[0] and h0[1] (outer/inner VLAN headers) without verifying that the packet actually contains enough VLAN headers / bytes in the buffer.
eth_vlan_table_lookups() may return hi == NULL for some inputs, and the code then calls eth_identify_subint(hi, ...), which can dereference NULL and crash.
Fix:
This patch hardens l2_efp_filter.c in two places:
Make extract_keys() safe
Initialize outer_id / inner_id to 0 by default.
Validate l2_len and current_length.
Clamp bytes-after-ethernet to what is actually available in the buffer.
Derive VLAN tag count safely and cap it to max 2 tags.
Only read VLAN headers when tag_num >= 1/2.
Guard eth_identify_subint()
Introduce safe_eth_identify_subint() wrapper.
If hi == NULL, avoid calling eth_identify_subint() and force a mismatch (set subint_sw_if_index = ~0), so the packet is dropped by the existing EFP filter logic instead of crashing.
Behavior / Impact:
No behavior change for valid packets and normal configurations.
For malformed/short frames or unexpected lookup results, VPP no longer crashes; packets are handled safely (typically dropped by EFP filter as intended).
Testing
Generated traffic on VLAN subinterfaces (e.g., .2000) and verified packets traverse l2-efp-filter without triggering a crash.
Verified l2-efp-filter counters increment and post-rewrite drop counter behaves as expected for mismatches.