Validate total_size in eBPF metadata headers - #5552
Open
Nicholas L (nmlud21) wants to merge 1 commit into
Open
Conversation
Signed-off-by: Nicholas Ludwig <nludwig@microsoft.com>
Nicholas L (nmlud21)
requested review from
Alan Jowett (Alan-Jowett),
Andrew Beltrano (abeltrano),
Dave Thaler (dthaler),
Laksh (lakshk98),
Matthew Ige (matthewige),
Maksim S. (maxsud),
D. Michael Agun (mikeagun),
Michael Friesen (mtfriesen),
poornagmsft,
Anurag Saxena (saxena-anurag) and
Shankar Seal (shankarseal)
as code owners
September 2, 2026 22:33
Contributor
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.
Description
ebpf_extension_header_t carries version, size, and total_size. _ebpf_validate_extension_object_header validated only version and size, total_size was never bounded, yet it was used verbatim as both an array stride and a memcpy length into fixed-size stack and pool destinations, an attacker-length, attacker-content kernel out-of-bounds write.
Changes
total_size— added_ebpf_extension_type_max_total_size[](parallel to the existing_supported_ebpf_extension_version[]); the validator now rejectstotal_size > sizeof(struct). One choke point closes every sink.total_sizeas a stride — 6 walkers inebpf_native.c+ 1 inshared_common.c. They previously read the stride from unvalidated memory.min(total_size, sizeof(dest))— 5 sites inebpf_native.c, 1 inshared_common.c; matches the existing_ebpf_copy_program_entryidiom.helper_prototype[i].flagsdouble-indexed an already-offset pointer behind a dead guard (byte count compared to a version constant).Testing
Ran unit_test passes.
Negative unit test for oversized total_size can be added.
Documentation
No
Installation
No