-
Notifications
You must be signed in to change notification settings - Fork 49
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
Intel ME FPT fixes #443
Intel ME FPT fixes #443
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #443 +/- ##
==========================================
- Coverage 34.22% 34.21% -0.01%
==========================================
Files 209 209
Lines 14087 14086 -1
==========================================
- Hits 4821 4820 -1
Misses 8377 8377
Partials 889 889
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
4bec2e6
to
6722304
Compare
pkg/uefi/meregion.go
Outdated
@@ -95,15 +95,20 @@ func (e MEPartitionEntry) Type() string { | |||
|
|||
// FindMEDescriptor searches for an Intel ME FTP signature | |||
func FindMEDescriptor(buf []byte) (int, error) { | |||
if bytes.Equal(buf[16:16+len(MEFTPSignature)], MEFTPSignature) { | |||
if bytes.Equal(buf[16:16+len(MEFPTSignature)], MEFPTSignature) { | |||
// 16 + 4 since the descriptor starts after the signature |
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.
why not just call bytes.Index?
Also, so many people depend on this, it needs to come with a test at this point (you found a bug! bad! bad!) :-)
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'm just extending the cases here. Since there is no public spec to my knowledge (I haven't found any) it's hard to say what would be correct. All this knowledge is based on RE.
There are cases where the assumption that the signature is either at the start or in the second 16 bytes holds, and me_cleaner does the same:
https://chromium.googlesource.com/chromiumos/third_party/coreboot/+/refs/heads/stabilize-12239.46.B/util/me_cleaner/me_cleaner.py#579
Looking at more and newer images though, other cases show up, so MEAnalyzer tries a bunch of variants as well, with different implications:
https://github.com/platomav/MEAnalyzer/blob/6d898a6d3972ccec53099e05c5e84ec2abe79197/MEA.py#L11604
So yea bug or... case unknown up until now.
Would you just list the cases known so far for the test cases? I'll see what I can do.
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.
Test added. Tbh I don't see the real value, since I am now testing bytes.Index()
... Would rather add some fixtures and use those instead. Then I'd be unsure because of ME binary distribution issues.
4ad1bbf
to
8572ace
Compare
Removed the now needless dump of the first 20 bytes on error. The signature could be anywhere in the ME region. |
8572ace
to
ca2d87a
Compare
... making the linter happy |
Signed-off-by: Daniel Maslowski <[email protected]>
Easily confused: FPTR is the name of one partition, whereas FPT is the Firmware Partition Table (as far as we know). Signed-off-by: Daniel Maslowski <[email protected]>
MEAnalyzer does the same thing. There are images where the FPT is not at the beginning of the ME region, e.g.: https://www.gigabyte.com/Motherboard/H410M-H-V3-rev-10-12/support#support-dl-bios Signed-off-by: Daniel Maslowski <[email protected]>
…ound Signed-off-by: Daniel Maslowski <[email protected]>
Signed-off-by: Daniel Maslowski <[email protected]>
noticed that the only reference where information was taken from is now gone, so added the archive snapshot and more references |
ca2d87a
to
c1ff9b1
Compare
if r != test.res { | ||
t.Errorf("got position %d want %d (%q)", r, test.res, e) | ||
} | ||
if test.res == -1 && e == nil { |
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.
you can put an err error member in the structure, and use errors.Is(err, test.err)
That would allow tests that succeed.
No description provided.