Skip to contentSkip to conversation

efi: generalize efi_get_secureboot

PATCH Ard Biesheuvel 2 participants 2 messages Nov 4, 2020 – Nov 5, 2020 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 34 lines · Mimi Zohar
Quoted 32 lines · kernel test robot

Hi Chester,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on efi/next]
[also build test WARNING on arm64/for-next/core integrity/next-integrity v5.10-rc2 next-20201103] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chester-Lin/add-ima_arch-support-for-ARM64/20201030-141043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next
config: i386-randconfig-s031-20201103 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-76-gf680124b-dirty
        # https://github.com/0day-ci/linux/commit/945001ead079043268e8ad1b9d1df9bd5cabf020
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Chester-Lin/add-ima_arch-support-for-ARM64/20201030-141043
        git checkout 945001ead079043268e8ad1b9d1df9bd5cabf020
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

If you fix the issue, kindly add following tag as appropriate

"sparse warnings: (new ones prefixed by >>)"

Quoted 3 lines
Quoted 3 lines

drivers/firmware/efi/libstub/tpm.c:36:30: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected unsigned short [usertype] *name @@ got unsigned short const * @@
drivers/firmware/efi/libstub/tpm.c:36:30: sparse: expected unsigned short [usertype] *name
drivers/firmware/efi/libstub/tpm.c:36:30: sparse: got unsigned short const *

Quoted 8 lines
Quoted 4 lines

drivers/firmware/efi/libstub/tpm.c:42:21: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected unsigned short [usertype] *name @@ got unsigned short const * @@
drivers/firmware/efi/libstub/tpm.c:42:21: sparse: expected unsigned short [usertype] *name
drivers/firmware/efi/libstub/tpm.c:42:21: sparse: got unsigned short const *

This seems to be the result of commit 36b649760e94 ("efi: Use string literals for efi_char16_t variable initializers"), not this patch.

Indeed. tpm.c is not even touched by the patch in question afaict.

Quoted 42 lines
Quoted 40 lines

vim +36 drivers/firmware/efi/libstub/tpm.c

ccc829ba3624beb Matthew Garrett   2017-08-25  15
33b6d03469b2206 Thiebaud Weksteen 2017-09-20  16  #ifdef CONFIG_RESET_ATTACK_MITIGATION
36b649760e94968 Ard Biesheuvel    2018-03-12  17  static const efi_char16_t efi_MemoryOverWriteRequest_name[] =
36b649760e94968 Ard Biesheuvel    2018-03-12  18      L"MemoryOverwriteRequestControl";
ccc829ba3624beb Matthew Garrett   2017-08-25  19
ccc829ba3624beb Matthew Garrett   2017-08-25  20  #define MEMORY_ONLY_RESET_CONTROL_GUID \
ccc829ba3624beb Matthew Garrett   2017-08-25  21      EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29)
ccc829ba3624beb Matthew Garrett   2017-08-25  22
ccc829ba3624beb Matthew Garrett   2017-08-25  23  /*
ccc829ba3624beb Matthew Garrett   2017-08-25  24   * Enable reboot attack mitigation. This requests that the firmware clear the
ccc829ba3624beb Matthew Garrett   2017-08-25  25   * RAM on next reboot before proceeding with boot, ensuring that any secrets
ccc829ba3624beb Matthew Garrett   2017-08-25  26   * are cleared. If userland has ensured that all secrets have been removed
ccc829ba3624beb Matthew Garrett   2017-08-25  27   * from RAM before reboot it can simply reset this variable.
ccc829ba3624beb Matthew Garrett   2017-08-25  28   */
cd33a5c1d53e43b Ard Biesheuvel    2019-12-24  29  void efi_enable_reset_attack_mitigation(void)
ccc829ba3624beb Matthew Garrett   2017-08-25  30  {
ccc829ba3624beb Matthew Garrett   2017-08-25  31      u8 val = 1;
ccc829ba3624beb Matthew Garrett   2017-08-25  32      efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID;
ccc829ba3624beb Matthew Garrett   2017-08-25  33      efi_status_t status;
ccc829ba3624beb Matthew Garrett   2017-08-25  34      unsigned long datasize = 0;
ccc829ba3624beb Matthew Garrett   2017-08-25  35
ccc829ba3624beb Matthew Garrett   2017-08-25 @36      status = get_efi_var(efi_MemoryOverWriteRequest_name, &var_guid,
ccc829ba3624beb Matthew Garrett   2017-08-25  37                           NULL, &datasize, NULL);
ccc829ba3624beb Matthew Garrett   2017-08-25  38
ccc829ba3624beb Matthew Garrett   2017-08-25  39      if (status == EFI_NOT_FOUND)
ccc829ba3624beb Matthew Garrett   2017-08-25  40              return;
ccc829ba3624beb Matthew Garrett   2017-08-25  41
ccc829ba3624beb Matthew Garrett   2017-08-25  42      set_efi_var(efi_MemoryOverWriteRequest_name, &var_guid,
ccc829ba3624beb Matthew Garrett   2017-08-25  43                  EFI_VARIABLE_NON_VOLATILE |
ccc829ba3624beb Matthew Garrett   2017-08-25  44                  EFI_VARIABLE_BOOTSERVICE_ACCESS |
ccc829ba3624beb Matthew Garrett   2017-08-25  45                  EFI_VARIABLE_RUNTIME_ACCESS, sizeof(val), &val);
ccc829ba3624beb Matthew Garrett   2017-08-25  46  }

33b6d03469b2206 Thiebaud Weksteen 2017-09-20 47

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
Quoted 40 lines · Ard Biesheuvel
Quoted 39 lines · Mimi Zohar
Quoted 36 lines · kernel test robot

Hi Chester,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on efi/next]
[also build test WARNING on arm64/for-next/core integrity/next-integrity v5.10-rc2 next-20201103] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chester-Lin/add-ima_arch-support-for-ARM64/20201030-141043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next
config: i386-randconfig-s031-20201103 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-76-gf680124b-dirty
        # https://github.com/0day-ci/linux/commit/945001ead079043268e8ad1b9d1df9bd5cabf020
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Chester-Lin/add-ima_arch-support-for-ARM64/20201030-141043
        git checkout 945001ead079043268e8ad1b9d1df9bd5cabf020
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

If you fix the issue, kindly add following tag as appropriate

"sparse warnings: (new ones prefixed by >>)"

Quoted 3 lines
Quoted 3 lines

drivers/firmware/efi/libstub/tpm.c:36:30: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected unsigned short [usertype] *name @@ got unsigned short const * @@
drivers/firmware/efi/libstub/tpm.c:36:30: sparse: expected unsigned short [usertype] *name
drivers/firmware/efi/libstub/tpm.c:36:30: sparse: got unsigned short const *

drivers/firmware/efi/libstub/tpm.c:42:21: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected unsigned short [usertype] *name @@ got unsigned short const * @@
drivers/firmware/efi/libstub/tpm.c:42:21: sparse: expected unsigned short [usertype] *name
drivers/firmware/efi/libstub/tpm.c:42:21: sparse: got unsigned short const *

Quoted 5 lines
Quoted 3 lines

This seems to be the result of commit 36b649760e94 ("efi: Use string literals for efi_char16_t variable initializers"), not this patch.

Indeed. tpm.c is not even touched by the patch in question afaict.

sorry for false positive, we will look into it to resolve ths issue.

Quoted 48 lines
Quoted 40 lines
Quoted 40 lines

vim +36 drivers/firmware/efi/libstub/tpm.c

ccc829ba3624beb Matthew Garrett   2017-08-25  15
33b6d03469b2206 Thiebaud Weksteen 2017-09-20  16  #ifdef CONFIG_RESET_ATTACK_MITIGATION
36b649760e94968 Ard Biesheuvel    2018-03-12  17  static const efi_char16_t efi_MemoryOverWriteRequest_name[] =
36b649760e94968 Ard Biesheuvel    2018-03-12  18      L"MemoryOverwriteRequestControl";
ccc829ba3624beb Matthew Garrett   2017-08-25  19
ccc829ba3624beb Matthew Garrett   2017-08-25  20  #define MEMORY_ONLY_RESET_CONTROL_GUID \
ccc829ba3624beb Matthew Garrett   2017-08-25  21      EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29)
ccc829ba3624beb Matthew Garrett   2017-08-25  22
ccc829ba3624beb Matthew Garrett   2017-08-25  23  /*
ccc829ba3624beb Matthew Garrett   2017-08-25  24   * Enable reboot attack mitigation. This requests that the firmware clear the
ccc829ba3624beb Matthew Garrett   2017-08-25  25   * RAM on next reboot before proceeding with boot, ensuring that any secrets
ccc829ba3624beb Matthew Garrett   2017-08-25  26   * are cleared. If userland has ensured that all secrets have been removed
ccc829ba3624beb Matthew Garrett   2017-08-25  27   * from RAM before reboot it can simply reset this variable.
ccc829ba3624beb Matthew Garrett   2017-08-25  28   */
cd33a5c1d53e43b Ard Biesheuvel    2019-12-24  29  void efi_enable_reset_attack_mitigation(void)
ccc829ba3624beb Matthew Garrett   2017-08-25  30  {
ccc829ba3624beb Matthew Garrett   2017-08-25  31      u8 val = 1;
ccc829ba3624beb Matthew Garrett   2017-08-25  32      efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID;
ccc829ba3624beb Matthew Garrett   2017-08-25  33      efi_status_t status;
ccc829ba3624beb Matthew Garrett   2017-08-25  34      unsigned long datasize = 0;
ccc829ba3624beb Matthew Garrett   2017-08-25  35
ccc829ba3624beb Matthew Garrett   2017-08-25 @36      status = get_efi_var(efi_MemoryOverWriteRequest_name, &var_guid,
ccc829ba3624beb Matthew Garrett   2017-08-25  37                           NULL, &datasize, NULL);
ccc829ba3624beb Matthew Garrett   2017-08-25  38
ccc829ba3624beb Matthew Garrett   2017-08-25  39      if (status == EFI_NOT_FOUND)
ccc829ba3624beb Matthew Garrett   2017-08-25  40              return;
ccc829ba3624beb Matthew Garrett   2017-08-25  41
ccc829ba3624beb Matthew Garrett   2017-08-25  42      set_efi_var(efi_MemoryOverWriteRequest_name, &var_guid,
ccc829ba3624beb Matthew Garrett   2017-08-25  43                  EFI_VARIABLE_NON_VOLATILE |
ccc829ba3624beb Matthew Garrett   2017-08-25  44                  EFI_VARIABLE_BOOTSERVICE_ACCESS |
ccc829ba3624beb Matthew Garrett   2017-08-25  45                  EFI_VARIABLE_RUNTIME_ACCESS, sizeof(val), &val);
ccc829ba3624beb Matthew Garrett   2017-08-25  46  }

33b6d03469b2206 Thiebaud Weksteen 2017-09-20 47

Quoted 5 lines
Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

_______________________________________________
kbuild-all mailing list -- kbuild-all(a)lists.01.org To unsubscribe send an email to kbuild-all-leave(a)lists.01.org