Skip to content

Conversation

@jsetje
Copy link
Collaborator

@jsetje jsetje commented Feb 19, 2025

The CopyMem() introduced in
ad8692e avoid EFIv2 runtime services on Apple x86 machines copies 100 CHAR16s no matter what. NX enabled firmware catches this and the boot breaks on those systems.

https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html says that FirmwareVendor is a pointer to a null terminated string that identifies the vendor that produces the system firmware for the platform. If we can rely on it being null terminated then we don't need to copy the string at all.

@jsetje
Copy link
Collaborator Author

jsetje commented Feb 19, 2025

I'm not 100% sure that we can really count on the string being null terminated since other places also seem to just copy the first 100 char16s.

The CopyMem() introduced in "ad8692e avoid EFIv2 runtime services on
Apple x86 machines" copies 100 CHAR16s no matter what. NX enabled
firmware catches this and the boot breaks on those systems when the
value is smaller than that and it's up against a page boundary with a
page that's not mapped as readable.

https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html says
that FirmwareVendor is a pointer to a NUL terminated string that
identifies the vendor that produces the system firmware for the platform.

Signed-off-by: Jan Setje-Eilers <Jan.SetjeEilers@oracle.com>
Copy link
Member

@vathpela vathpela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jan and I have tested this and think it should work unless someone has done something truly unlikely with their string placement.

Which means we'll find out when someone has.

@vathpela vathpela merged commit 1294b47 into rhboot:main Feb 19, 2025
20 checks passed
@mikebeaton
Copy link
Contributor

mikebeaton commented Feb 24, 2025

Was there a reason not to just StrnCmp in place as in earlier commit of this PR? Possible (lack of) alignment?

Right, to allow print (of something, first five chars at least), even if no NUL terminator. (EDIT: No, that's still being done from the source - so would still run on if not NUL terminated.)

* So right now we're only copying ten bytes, because Apple is the
* only vendor we're testing against.
*/
CopyMem(vendorbuf, vendor, 10);
Copy link
Contributor

@mikebeaton mikebeaton Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if I'm missing something, but vendorbuf is not used after this CopyMem, but rather vendor, which looks like a mistake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @vathpela - I'm not sure if closed issues and merged PRs are monitored in this repo, i.e. should I create a new Issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess also ping @jsetje

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