diff options
| author | Yi Zhao <yi.zhao@windriver.com> | 2019-06-05 10:52:14 +0800 |
|---|---|---|
| committer | Jia Zhang <zhang.jia@linux.alibaba.com> | 2019-06-05 11:33:01 +0800 |
| commit | 6f94e34e05f441367b350e3c63917b1d212df9af (patch) | |
| tree | 95a11bb76d86ceba0ca3481bbf65d39fd8168540 | |
| parent | 8fc7d850d7e655ec14d8cbea29663f5eda6a6d89 (diff) | |
| download | meta-secure-core-6f94e34e05f441367b350e3c63917b1d212df9af.tar.gz | |
shim: fix build failure with gcc9
Backport patch to fix build error with gcc9 for option
"-Werror=address-of-packed-member"
MokManager.c: In function 'write_back_mok_list':
MokManager.c:1125:19: error: taking address of packed member of 'struct
<anonymous>' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
1125 | if (CompareGuid(&(list[i].Type), &CertType) == 0)
| ^~~~~~~~~~~~~~~
MokManager.c:1147:19: error: taking address of packed member of 'struct
<anonymous>' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
1147 | if (CompareGuid(&(list[i].Type), &CertType) == 0) {
| ^~~~~~~~~~~~~~~
MokManager.c: In function 'delete_cert':
MokManager.c:1188:19: error: taking address of packed member of 'struct
<anonymous>' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
1188 | if (CompareGuid(&(mok[i].Type), &CertType) != 0)
| ^~~~~~~~~~~~~~
MokManager.c: In function 'delete_hash_in_list':
MokManager.c:1239:20: error: taking address of packed member of 'struct
<anonymous>' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
1239 | if ((CompareGuid(&(mok[i].Type), &Type) != 0) ||
| ^~~~~~~~~~~~~~
MokManager.c: In function 'delete_keys':
MokManager.c:1410:19: error: taking address of packed member of 'struct
<anonymous>' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
1410 | if (CompareGuid(&(del_key[i].Type), &CertType) == 0) {
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
<builtin>: recipe for target 'MokManager.o' failed
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
| -rw-r--r-- | meta-efi-secure-boot/recipes-bsp/shim/shim/0001-MokManager-Use-CompareMem-on-MokListNode.Type-instea.patch | 75 | ||||
| -rw-r--r-- | meta-efi-secure-boot/recipes-bsp/shim/shim_git.bb | 1 |
2 files changed, 76 insertions, 0 deletions
diff --git a/meta-efi-secure-boot/recipes-bsp/shim/shim/0001-MokManager-Use-CompareMem-on-MokListNode.Type-instea.patch b/meta-efi-secure-boot/recipes-bsp/shim/shim/0001-MokManager-Use-CompareMem-on-MokListNode.Type-instea.patch new file mode 100644 index 0000000..ed91bde --- /dev/null +++ b/meta-efi-secure-boot/recipes-bsp/shim/shim/0001-MokManager-Use-CompareMem-on-MokListNode.Type-instea.patch | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | From 4747fa5ae785d264da717396ddc0429ef39d018b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Gary Lin <glin@suse.com> | ||
| 3 | Date: Tue, 26 Feb 2019 11:33:53 +0800 | ||
| 4 | Subject: [PATCH] MokManager: Use CompareMem on MokListNode.Type instead of | ||
| 5 | CompareGuid | ||
| 6 | |||
| 7 | Fix the errors from gcc9 '-Werror=address-of-packed-member' | ||
| 8 | |||
| 9 | https://github.com/rhboot/shim/issues/161 | ||
| 10 | |||
| 11 | Upstream-Status: Backport | ||
| 12 | [https://github.com/rhboot/shim/pull/170/commits/f30cd0b6330be8ea72a93bf25e43829c222ba611] | ||
| 13 | |||
| 14 | Signed-off-by: Gary Lin <glin@suse.com> | ||
| 15 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
| 16 | --- | ||
| 17 | MokManager.c | 14 +++++++++----- | ||
| 18 | 1 file changed, 9 insertions(+), 5 deletions(-) | ||
| 19 | |||
| 20 | diff --git a/MokManager.c b/MokManager.c | ||
| 21 | index 208c706..dd18249 100644 | ||
| 22 | --- a/MokManager.c | ||
| 23 | +++ b/MokManager.c | ||
| 24 | @@ -1122,7 +1122,8 @@ static EFI_STATUS write_back_mok_list (MokListNode *list, INTN key_num, | ||
| 25 | continue; | ||
| 26 | |||
| 27 | DataSize += sizeof(EFI_SIGNATURE_LIST); | ||
| 28 | - if (CompareGuid(&(list[i].Type), &CertType) == 0) | ||
| 29 | + if (CompareMem(&(list[i].Type), &CertType, | ||
| 30 | + sizeof(EFI_GUID)) == 0) | ||
| 31 | DataSize += sizeof(EFI_GUID); | ||
| 32 | DataSize += list[i].MokSize; | ||
| 33 | } | ||
| 34 | @@ -1144,7 +1145,8 @@ static EFI_STATUS write_back_mok_list (MokListNode *list, INTN key_num, | ||
| 35 | CertList->SignatureType = list[i].Type; | ||
| 36 | CertList->SignatureHeaderSize = 0; | ||
| 37 | |||
| 38 | - if (CompareGuid(&(list[i].Type), &CertType) == 0) { | ||
| 39 | + if (CompareMem(&(list[i].Type), &CertType, | ||
| 40 | + sizeof(EFI_GUID)) == 0) { | ||
| 41 | CertList->SignatureListSize = list[i].MokSize + | ||
| 42 | sizeof(EFI_SIGNATURE_LIST) + | ||
| 43 | sizeof(EFI_GUID); | ||
| 44 | @@ -1185,7 +1187,8 @@ static void delete_cert (void *key, UINT32 key_size, | ||
| 45 | int i; | ||
| 46 | |||
| 47 | for (i = 0; i < mok_num; i++) { | ||
| 48 | - if (CompareGuid(&(mok[i].Type), &CertType) != 0) | ||
| 49 | + if (CompareMem(&(mok[i].Type), &CertType, | ||
| 50 | + sizeof(EFI_GUID)) != 0) | ||
| 51 | continue; | ||
| 52 | |||
| 53 | if (mok[i].MokSize == key_size && | ||
| 54 | @@ -1236,7 +1239,7 @@ static void delete_hash_in_list (EFI_GUID Type, UINT8 *hash, UINT32 hash_size, | ||
| 55 | sig_size = hash_size + sizeof(EFI_GUID); | ||
| 56 | |||
| 57 | for (i = 0; i < mok_num; i++) { | ||
| 58 | - if ((CompareGuid(&(mok[i].Type), &Type) != 0) || | ||
| 59 | + if ((CompareMem(&(mok[i].Type), &Type, sizeof(EFI_GUID)) != 0) || | ||
| 60 | (mok[i].MokSize < sig_size)) | ||
| 61 | continue; | ||
| 62 | |||
| 63 | @@ -1407,7 +1410,8 @@ static EFI_STATUS delete_keys (void *MokDel, UINTN MokDelSize, BOOLEAN MokX) | ||
| 64 | |||
| 65 | /* Search and destroy */ | ||
| 66 | for (i = 0; i < del_num; i++) { | ||
| 67 | - if (CompareGuid(&(del_key[i].Type), &CertType) == 0) { | ||
| 68 | + if (CompareMem(&(del_key[i].Type), &CertType, | ||
| 69 | + sizeof(EFI_GUID)) == 0) { | ||
| 70 | delete_cert(del_key[i].Mok, del_key[i].MokSize, | ||
| 71 | mok, mok_num); | ||
| 72 | } else if (is_sha2_hash(del_key[i].Type)) { | ||
| 73 | -- | ||
| 74 | 2.7.4 | ||
| 75 | |||
diff --git a/meta-efi-secure-boot/recipes-bsp/shim/shim_git.bb b/meta-efi-secure-boot/recipes-bsp/shim/shim_git.bb index fb58727..b5b71c9 100644 --- a/meta-efi-secure-boot/recipes-bsp/shim/shim_git.bb +++ b/meta-efi-secure-boot/recipes-bsp/shim/shim_git.bb | |||
| @@ -27,6 +27,7 @@ SRC_URI = "\ | |||
| 27 | file://0008-Fix-the-world-build-failure-due-to-the-missing-rule-.patch \ | 27 | file://0008-Fix-the-world-build-failure-due-to-the-missing-rule-.patch \ |
| 28 | file://0011-Update-verification_method-if-the-loaded-image-is-si.patch;apply=0 \ | 28 | file://0011-Update-verification_method-if-the-loaded-image-is-si.patch;apply=0 \ |
| 29 | file://0012-netboot-replace-the-depreciated-EFI_PXE_BASE_CODE.patch \ | 29 | file://0012-netboot-replace-the-depreciated-EFI_PXE_BASE_CODE.patch \ |
| 30 | file://0001-MokManager-Use-CompareMem-on-MokListNode.Type-instea.patch \ | ||
| 30 | " | 31 | " |
| 31 | SRC_URI_append_x86-64 = "\ | 32 | SRC_URI_append_x86-64 = "\ |
| 32 | ${@bb.utils.contains('DISTRO_FEATURES', 'msft', \ | 33 | ${@bb.utils.contains('DISTRO_FEATURES', 'msft', \ |
