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

Segmentation fault in create_mb_refstate script #1153

Closed
ansasaki opened this issue Nov 4, 2022 · 1 comment · Fixed by #1154
Closed

Segmentation fault in create_mb_refstate script #1153

ansasaki opened this issue Nov 4, 2022 · 1 comment · Fixed by #1154

Comments

@ansasaki
Copy link
Contributor

ansasaki commented Nov 4, 2022

Is your issue a feature request? If so, please raise it as an enhancement

Environment

  • OS / version: N/A
  • Processor architecture: N/A
  • TPM Manufacturer: N/A
  • Keylime version: current master (7033891)

Description

Segmentation fault in create_mb_refstate depending on the input provided.

Expected behavior vs. actual behavior

The script should run normally instead of core dump with segmentation fault

Steps to reproduce problem

  1. Change directory to scripts
  2. Download the mb_log_b64.txt linked below
  3. Decode with base64 -d mb_log_b64.txt > mb_log.bin
  4. Run ./create_mb_refstate mb_log.bin mb_refstate.json

Relevant logs

Attach any relevant log files that can help to debug your issue.

ansasaki added a commit to ansasaki/keylime that referenced this issue Nov 4, 2022
In enrich_device_path(), get the length of DevicePath from the field
LengthOfDevicePath instead of calculating the length from the bytes
array.

This avoids a segmentation fault when processing the measured boot event
log in create_mb_refstate script.

This is called for the events "EV_EFI_BOOT_SERVICES_APPLICATION",
"EV_EFI_BOOT_SERVICES_DRIVER", and "EV_EFI_RUNTIME_SERVICES_DRIVER".

Fixes: keylime#1153

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
@stefanberger
Copy link
Contributor

This here seems to be a solution but I don't know whether this is the correct way of handling it? @maugustosilva , @galmasi ?

diff --git a/keylime/tpm_bootlog_enrich.py b/keylime/tpm_bootlog_enrich.py
index ef8e9f7..a817d6e 100644
--- a/keylime/tpm_bootlog_enrich.py
+++ b/keylime/tpm_bootlog_enrich.py
@@ -47,6 +47,8 @@ efivarlib_functions = CDLL(config.LIBEFIVAR)


 def getDevicePath(b):
+    if b == b'\x00' * 8:
+        return ""
     ret = efivarlib_functions.efidp_format_device_path(0, 0, b, len(b))
     if ret < 0:
         raise Exception(f"getDevicePath: efidp_format_device_path({b}) returned {ret}")

mpeters pushed a commit that referenced this issue Nov 7, 2022
In enrich_device_path(), get the length of DevicePath from the field
LengthOfDevicePath instead of calculating the length from the bytes
array.

This avoids a segmentation fault when processing the measured boot event
log in create_mb_refstate script.

This is called for the events "EV_EFI_BOOT_SERVICES_APPLICATION",
"EV_EFI_BOOT_SERVICES_DRIVER", and "EV_EFI_RUNTIME_SERVICES_DRIVER".

Fixes: #1153

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.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 a pull request may close this issue.

2 participants