[PATCH 1/3] uefi: uefidump: add support for db, dbx, dbt... variables scan (LP:#1247749)

Colin Ian King colin.king at canonical.com
Fri Nov 8 08:53:34 UTC 2013


On 08/11/13 05:56, Ivan Hu wrote:
> Add the parser function for scanning the variables db, dbt, dbx, dbDefault,
> dbxDefault, dbtDefault.
> 
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |    7 ++++++
>  src/uefi/uefidump/uefidump.c |   50 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index 512ca67..a64be92 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -363,6 +363,13 @@ typedef struct {
>    	char description[0];
>  } fwts_uefi_bios_dev_path;
>  
> +typedef struct {
> +	fwts_uefi_guid signaturetype;
> +	uint32_t signaturelistsize;
> +	uint32_t signatureheadersize;
> +	uint32_t signaturesize;
> +} __attribute__((packed)) fwts_uefi_signature_list;
> +
>  void fwts_uefi_str16_to_str(char *dst, const size_t len, const uint16_t *src);
>  size_t fwts_uefi_str16len(const uint16_t *str);
>  void fwts_uefi_get_varname(char *varname, const size_t len, const fwts_uefi_var *var);
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 060f693..c8c6a35 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -47,6 +47,19 @@ static void uefidump_var_hexdump(fwts_framework *fw, fwts_uefi_var *var)
>  	}
>  }
>  
> +static void uefidump_data_hexdump(fwts_framework *fw, uint8_t *data, size_t size)
> +{
> +	size_t i;
> +
> +	for (i = 0; i < size; i+= 16) {
> +		char buffer[128];
> +		size_t left = size - i;
> +
> +		fwts_dump_raw_data(buffer, sizeof(buffer), data + i, i, left > 16 ? 16 : left);
> +		fwts_log_info_verbatum(fw,  "  Data: %s", buffer+2);
> +	}
> +}
> +
>  static char *uefidump_vprintf(char *str, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
>  
>  /*
> @@ -874,6 +887,42 @@ static void uefidump_info_keyoption(fwts_framework *fw, fwts_uefi_var *var)
>  	}
>  }
>  
> +static void uefidump_info_signaturedatabase(fwts_framework *fw, fwts_uefi_var *var)
> +{
> +	fwts_uefi_signature_list *signature_list;
> +	char guid_str[37];
> +	size_t offset = 0, list_start = 0;
> +
> +	if (var->datalen < sizeof(fwts_uefi_signature_list))
> +		return;
> +
> +	do {
> +		signature_list = (fwts_uefi_signature_list *)(var->data + list_start);
> +		fwts_guid_buf_to_str(var->data, guid_str, sizeof(guid_str));
> +		fwts_log_info_verbatum(fw, "  SignatureType: %s", guid_str);
> +		fwts_log_info_verbatum(fw, "  SignatureListSize: 0x%" PRIx32, signature_list->signaturelistsize);
> +		fwts_log_info_verbatum(fw, "  SignatureHeaderSize: 0x%" PRIx32, signature_list->signatureheadersize);
> +		fwts_log_info_verbatum(fw, "  SignatureSize: 0x%" PRIx32, signature_list->signaturesize);
> +
> +		offset = list_start + sizeof (fwts_uefi_signature_list);
> +		if (signature_list->signatureheadersize > 0) {
> +			fwts_log_info_verbatum(fw, "  SignatureHeader:");	
> +			uefidump_data_hexdump(fw, (uint8_t *)(var->data + offset), signature_list->signatureheadersize);
> +		}
> +		offset += signature_list->signatureheadersize;
> +		if (signature_list->signaturesize > 0) {
> +			fwts_guid_buf_to_str((uint8_t *)(var->data + offset), guid_str, sizeof(guid_str));
> +			fwts_log_info_verbatum(fw, "  SignatureOwner: %s", guid_str);
> +			offset += sizeof(fwts_uefi_guid);
> +			fwts_log_info_verbatum(fw, "  SignatureData:");
> +			uefidump_data_hexdump(fw, (uint8_t *)(var->data + offset), signature_list->signaturesize - sizeof(fwts_uefi_guid));
> +		}

After reading section 27.4.1 of version 2.4 of the UEFI specification I
expected to see 1 or more occurrences of signature data per signature
list, see figure 64 in the specification.  From what I see above, there
seems to be just once instance of signature data being dumped. Have I
misunderstood something?

> +
> +		list_start += signature_list->signaturelistsize;
> +
> +	} while ((var->datalen - list_start) > sizeof(fwts_uefi_signature_list));
> +
> +}
>  static uefidump_info uefidump_info_table[] = {
>  	{ "PlatformLangCodes",	uefidump_info_platform_langcodes },
>  	{ "PlatformLang",	uefidump_info_platform_lang },
> @@ -901,6 +950,7 @@ static uefidump_info uefidump_info_table[] = {
>  	{ "OsIndicationsSupported",	uefidump_info_osindications_supported },
>  	{ "VendorKeys",		uefidump_info_vendor_keys },
>  	{ "DriverOrder",	uefidump_info_driverorder },
> +	{ "db",			uefidump_info_signaturedatabase },
>  	{ NULL, NULL }
>  };
>  
> 




More information about the fwts-devel mailing list