Skip to content
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

Merged
merged 5 commits into from
Sep 29, 2024
Merged

Intel ME FPT fixes #443

merged 5 commits into from
Sep 29, 2024

Conversation

orangecms
Copy link
Collaborator

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.21%. Comparing base (d9260b5) to head (c1ff9b1).

❗ 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              
Flag Coverage Δ
34.21% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -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
Copy link
Contributor

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!) :-)

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

pkg/uefi/meregion.go Outdated Show resolved Hide resolved
@orangecms orangecms force-pushed the me-fpt-fixes branch 4 times, most recently from 4ad1bbf to 8572ace Compare September 29, 2024 10:01
@orangecms
Copy link
Collaborator Author

Removed the now needless dump of the first 20 bytes on error. The signature could be anywhere in the ME region.

@orangecms
Copy link
Collaborator Author

... making the linter happy

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]>
@orangecms
Copy link
Collaborator Author

noticed that the only reference where information was taken from is now gone, so added the archive snapshot and more references

if r != test.res {
t.Errorf("got position %d want %d (%q)", r, test.res, e)
}
if test.res == -1 && e == nil {
Copy link
Contributor

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.

@orangecms orangecms merged commit 978160d into linuxboot:main Sep 29, 2024
12 checks passed
@orangecms orangecms deleted the me-fpt-fixes branch September 29, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants