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

Add validation function for Microsoft signing #531

Closed
wants to merge 1 commit into from
Closed

Add validation function for Microsoft signing #531

wants to merge 1 commit into from

Conversation

dennis-tseng99
Copy link
Contributor

A validation function is added to post-process-pe.c to verify 3 flags required by Microsoft signing right after each EFI file has been built.

Like other functions existing in post-process-pe.c, this function can be enabled through the "-m" flag by CLI command. Default is enabled.

The output is something like this:
./post-process-pe -vv shim.efi
set_dll_characteristics():358: Updating DLL Characteristics from 0x0000 to 0x0100 ms_validation():373: NX-Compat-Flag: PASS
ms_validation():378: 4K-Alignment: PASS
ms_validation():390: Section-Wr-Exe: PASS

Microsoft is enforcing the validationis for all applications to be signed by the Microsoft third-party Unified Extensible Firmware Interface (UEFI) Certificate Authority (CA). These validations include:

  • Section Alignment of the submitted PE file must be aligned with page size. This must be 4kb.
  • Section Flags must not combine IMAGE_SCN_MEM_WRITE and IMAGE_SCN_MEM_EXECUTE for any given section.
  • DLL Characteristics must include IMAGE_DLLCHARACTERISTICS_NX_COMPAT

Please refer the following for more details:
https://techcommunity.microsoft.com/t5/hardware-dev-center/new-uefi-ca-memory-mitigation-requirements-for-signing/ba-p/3608714

Signed-off-by: Dennis Tseng [email protected]

Copy link
Collaborator

@julian-klode julian-klode left a comment

Choose a reason for hiding this comment

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

static storage modifier has been removed from variables and functions. This is (a) an unrelated change and (b) wrong, they are static (this also removes the need for the = 0 initializer at the top).

@dennis-tseng99
Copy link
Contributor Author

Thank Julian's comment. About:
(a) I agree. I will put "static" back.
(b) I don't agree. The initial value of non-static global variable in .bss is also 0. I put 0 to it is just for easy to read code.

Copy link
Member

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

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

Changing the nx compat default is a separate PR. Either drop the change or depend on that commit.

@dennis-tseng99
Copy link
Contributor Author

Thank Frozencemetery's comment. Yes, you are right. The nx compat default is a separate PR. I will drop the NX change.

A validation function is added to post-process-pe.c to verify 3 flags
required by Microsoft signing right after each EFI file has been built.

Like other functions existing in post-process-pe.c, this function can
be enabled through the "-m" flag by CLI command. Default is enabled.

The output is something like this:
./post-process-pe -vv shim.efi
set_dll_characteristics():358: Updating DLL Characteristics from 0x0000 to 0x0100
ms_validation():373: NX-Compat-Flag: PASS
ms_validation():378:   4K-Alignment: PASS
ms_validation():390: Section-Wr-Exe: PASS

Microsoft is enforcing the validationis for all applications to be signed
by the Microsoft third-party Unified Extensible Firmware Interface (UEFI)
Certificate Authority (CA). These validations include:

- Section Alignment of the submitted PE file must be aligned with page size.
  This must be 4kb.
- Section Flags must not combine IMAGE_SCN_MEM_WRITE and IMAGE_SCN_MEM_EXECUTE
  for any given section.
- DLL Characteristics must include IMAGE_DLLCHARACTERISTICS_NX_COMPAT

Please refer the following for more details:
https://techcommunity.microsoft.com/t5/hardware-dev-center/new-uefi-ca-memory-mitigation-requirements-for-signing/ba-p/3608714

recover "static" storage modifier.
recover "set_nx_compat" to false.

Signed-off-by: Dennis Tseng <[email protected]>
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