Skip to content

Conversation

@rosslagerwall
Copy link

The existing code copies an unchecked number of bytes onto the stack, adds padding, and then digests that. Instead, digest it directly and then digest the padding separately to avoid the memset and copy onto the stack. At the same time, make the debug message more useful since previously it wrote out an arbitrary userspace pointer.

Before:

...
pesum: 1747920082.420641 cms_pe_common.c:generate_digest():265: digesting ba000 + 1c000 pesum: 1747920082.420692 cms_pe_common.c:generate_digest():265: digesting d6000 + 1000 pesum: 1747920082.421691 cms_pe_common.c:generate_digest():285: digesting 7fffdec34af0 + 1f340 pesum: 1747920082.421744 cms_pe_common.c:generate_digest():293: end of hash ee8240fefb898334933d7a34a6c0d2a9774c13f8c3e58ac0111393b3fdbffd7c shimx64-unsigned.efi

After:

...
pesum: 1747920070.894430 cms_pe_common.c:generate_digest():265: digesting ba000 + 1c000 pesum: 1747920070.894489 cms_pe_common.c:generate_digest():265: digesting d6000 + 1000 pesum: 1747920070.895417 cms_pe_common.c:generate_digest():279: digesting d7000 + 1f33d pesum: 1747920070.895439 cms_pe_common.c:generate_digest():286: padding to 1f340 pesum: 1747920070.895452 cms_pe_common.c:generate_digest():289: end of hash ee8240fefb898334933d7a34a6c0d2a9774c13f8c3e58ac0111393b3fdbffd7c shimx64-unsigned.efi

The existing code copies an unchecked number of bytes onto the stack,
adds padding, and then digests that. Instead, digest it directly and then
digest the padding separately to avoid the memset and copy onto the
stack. At the same time, make the debug message more useful since
previously it wrote out an arbitrary userspace pointer.

Before:

...
pesum: 1747920082.420641 cms_pe_common.c:generate_digest():265: digesting ba000 + 1c000
pesum: 1747920082.420692 cms_pe_common.c:generate_digest():265: digesting d6000 + 1000
pesum: 1747920082.421691 cms_pe_common.c:generate_digest():285: digesting 7fffdec34af0 + 1f340
pesum: 1747920082.421744 cms_pe_common.c:generate_digest():293: end of hash
ee8240fefb898334933d7a34a6c0d2a9774c13f8c3e58ac0111393b3fdbffd7c shimx64-unsigned.efi

After:

...
pesum: 1747920070.894430 cms_pe_common.c:generate_digest():265: digesting ba000 + 1c000
pesum: 1747920070.894489 cms_pe_common.c:generate_digest():265: digesting d6000 + 1000
pesum: 1747920070.895417 cms_pe_common.c:generate_digest():279: digesting d7000 + 1f33d
pesum: 1747920070.895439 cms_pe_common.c:generate_digest():286: padding to 1f340
pesum: 1747920070.895452 cms_pe_common.c:generate_digest():289: end of hash
ee8240fefb898334933d7a34a6c0d2a9774c13f8c3e58ac0111393b3fdbffd7c shimx64-unsigned.efi

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
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.

1 participant