{{ message }}
fbpt: reject undersized record lengths before subtraction#3643
Open
alhudz wants to merge 2 commits into
Open
Conversation
Signed-off-by: alhudz <al.hudz.k@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3643 +/- ##
==========================================
+ Coverage 60.86% 60.89% +0.02%
==========================================
Files 659 659
Lines 46494 46500 +6
==========================================
+ Hits 28299 28314 +15
+ Misses 18195 18186 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Repro:feed an FBPT whose dynamic-string record declares aLengthbelow 34 (the 4-byte record header plus the 30 fixed bytes); seepkg/acpi/fpdt/fbpt/fbpt_test.go.Expected:the parser rejects the short record.Actual:recordLength-34underflows theuint8, somake([]byte, recordLength-34)sizes up to 255 bytes andio.ReadFullcopies that much adjacent memory intoDescription. The same unsigned-underflow shape sits inFindAllFBPTRecords:tablelength-8(uint32) in the loop bound andHeaderInfo.Length-4(uint8) before the skipSeek, both fed straight from the firmware table.Fix:check each length is at least the fixed size it is about to have subtracted, returning an error otherwise.Verified the
recordLength<34case reads 252 bytes of trailing data intoDescriptionbefore the patch and errors after.