1. 09 7月, 2020 1 次提交
    • A
      efi/efivars: Expose RT service availability via efivars abstraction · f88814cc
      Ard Biesheuvel 提交于
      Commit
      
        bf67fad1 ("efi: Use more granular check for availability for variable services")
      
      introduced a check into the efivarfs, efi-pstore and other drivers that
      aborts loading of the module if not all three variable runtime services
      (GetVariable, SetVariable and GetNextVariable) are supported. However, this
      results in efivarfs being unavailable entirely if only SetVariable support
      is missing, which is only needed if you want to make any modifications.
      Also, efi-pstore and the sysfs EFI variable interface could be backed by
      another implementation of the 'efivars' abstraction, in which case it is
      completely irrelevant which services are supported by the EFI firmware.
      
      So make the generic 'efivars' abstraction dependent on the availibility of
      the GetVariable and GetNextVariable EFI runtime services, and add a helper
      'efivar_supports_writes()' to find out whether the currently active efivars
      abstraction supports writes (and wire it up to the availability of
      SetVariable for the generic one).
      
      Then, use the efivar_supports_writes() helper to decide whether to permit
      efivarfs to be mounted read-write, and whether to enable efi-pstore or the
      sysfs EFI variable interface altogether.
      
      Fixes: bf67fad1 ("efi: Use more granular check for availability for variable services")
      Reported-by: NHeinrich Schuchardt <xypron.glpk@gmx.de>
      Acked-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Tested-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      f88814cc
  2. 16 6月, 2020 1 次提交
  3. 15 6月, 2020 1 次提交
    • G
      efi: Replace zero-length array and use struct_size() helper · 29637951
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      Lastly, make use of the sizeof_field() helper instead of an open-coded
      version.
      
      This issue was found with the help of Coccinelle and audited _manually_.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20200527171425.GA4053@embeddedorSigned-off-by: NArd Biesheuvel <ardb@kernel.org>
      29637951
  4. 10 6月, 2020 1 次提交
  5. 17 5月, 2020 1 次提交
  6. 24 4月, 2020 2 次提交
    • A
      efi: Move arch_tables check to caller · 4eb8320b
      Ard Biesheuvel 提交于
      Instead of making match_config_table() test its table_types pointer for
      NULL-ness, omit the call entirely if no arch_tables pointer was provided
      to efi_config_parse_tables().
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4eb8320b
    • A
      efi: Clean up config table description arrays · 4e9a0f73
      Ard Biesheuvel 提交于
      Increase legibility by adding whitespace to the efi_config_table_type_t
      arrays that describe which EFI config tables we look for when going over
      the firmware provided list. While at it, replace the 'name' char pointer
      with a char array, which is more space efficient on relocatable 64-bit
      kernels, as it avoids a 8 byte pointer and the associated relocation
      data (24 bytes when using RELA format)
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4e9a0f73
  7. 08 3月, 2020 1 次提交
    • A
      efi/x86: Ignore the memory attributes table on i386 · dd09fad9
      Ard Biesheuvel 提交于
      Commit:
      
        3a6b6c6f ("efi: Make EFI_MEMORY_ATTRIBUTES_TABLE initialization common across all architectures")
      
      moved the call to efi_memattr_init() from ARM specific to the generic
      EFI init code, in order to be able to apply the restricted permissions
      described in that table on x86 as well.
      
      We never enabled this feature fully on i386, and so mapping and
      reserving this table is pointless. However, due to the early call to
      memblock_reserve(), the memory bookkeeping gets confused to the point
      where it produces the splat below when we try to map the memory later
      on:
      
        ------------[ cut here ]------------
        ioremap on RAM at 0x3f251000 - 0x3fa1afff
        WARNING: CPU: 0 PID: 0 at arch/x86/mm/ioremap.c:166 __ioremap_caller ...
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.20.0 #48
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
        EIP: __ioremap_caller.constprop.0+0x249/0x260
        Code: 90 0f b7 05 4e 38 40 de 09 45 e0 e9 09 ff ff ff 90 8d 45 ec c6 05 ...
        EAX: 00000029 EBX: 00000000 ECX: de59c228 EDX: 00000001
        ESI: 3f250fff EDI: 00000000 EBP: de3edf20 ESP: de3edee0
        DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00200296
        CR0: 80050033 CR2: ffd17000 CR3: 1e58c000 CR4: 00040690
        Call Trace:
         ioremap_cache+0xd/0x10
         ? old_map_region+0x72/0x9d
         old_map_region+0x72/0x9d
         efi_map_region+0x8/0xa
         efi_enter_virtual_mode+0x260/0x43b
         start_kernel+0x329/0x3aa
         i386_start_kernel+0xa7/0xab
         startup_32_smp+0x164/0x168
        ---[ end trace e15ccf6b9f356833 ]---
      
      Let's work around this by disregarding the memory attributes table
      altogether on i386, which does not result in a loss of functionality
      or protection, given that we never consumed the contents.
      
      Fixes: 3a6b6c6f ("efi: Make EFI_MEMORY_ATTRIBUTES_TABLE ... ")
      Tested-by: NArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200304165917.5893-1-ardb@kernel.org
      Link: https://lore.kernel.org/r/20200308080859.21568-21-ardb@kernel.org
      dd09fad9
  8. 03 3月, 2020 1 次提交
  9. 29 2月, 2020 3 次提交
  10. 26 2月, 2020 1 次提交
  11. 24 2月, 2020 15 次提交
  12. 20 1月, 2020 1 次提交
  13. 10 12月, 2019 1 次提交
  14. 08 12月, 2019 1 次提交
  15. 07 11月, 2019 2 次提交
    • D
      efi: Common enable/disable infrastructure for EFI soft reservation · b617c526
      Dan Williams 提交于
      UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the
      interpretation of the EFI Memory Types as "reserved for a specific
      purpose".
      
      The proposed Linux behavior for specific purpose memory is that it is
      reserved for direct-access (device-dax) by default and not available for
      any kernel usage, not even as an OOM fallback.  Later, through udev
      scripts or another init mechanism, these device-dax claimed ranges can
      be reconfigured and hot-added to the available System-RAM with a unique
      node identifier. This device-dax management scheme implements "soft" in
      the "soft reserved" designation by allowing some or all of the
      reservation to be recovered as typical memory. This policy can be
      disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with
      efi=nosoftreserve.
      
      As for this patch, define the common helpers to determine if the
      EFI_MEMORY_SP attribute should be honored. The determination needs to be
      made early to prevent the kernel from being loaded into soft-reserved
      memory, or otherwise allowing early allocations to land there. Follow-on
      changes are needed per architecture to leverage these helpers in their
      respective mem-init paths.
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b617c526
    • D
      efi: Enumerate EFI_MEMORY_SP · fe3e5e65
      Dan Williams 提交于
      UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the
      interpretation of the EFI Memory Types as "reserved for a specific
      purpose". The intent of this bit is to allow the OS to identify precious
      or scarce memory resources and optionally manage it separately from
      EfiConventionalMemory. As defined older OSes that do not know about this
      attribute are permitted to ignore it and the memory will be handled
      according to the OS default policy for the given memory type.
      
      In other words, this "specific purpose" hint is deliberately weaker than
      EfiReservedMemoryType in that the system continues to operate if the OS
      takes no action on the attribute. The risk of taking no action is
      potentially unwanted / unmovable kernel allocations from the designated
      resource that prevent the full realization of the "specific purpose".
      For example, consider a system with a high-bandwidth memory pool. Older
      kernels are permitted to boot and consume that memory as conventional
      "System-RAM" newer kernels may arrange for that memory to be set aside
      (soft reserved) by the system administrator for a dedicated
      high-bandwidth memory aware application to consume.
      
      Specifically, this mechanism allows for the elimination of scenarios
      where platform firmware tries to game OS policy by lying about ACPI SLIT
      values, i.e. claiming that a precious memory resource has a high
      distance to trigger the OS to avoid it by default. This reservation hint
      allows platform-firmware to instead tell the truth about performance
      characteristics by indicate to OS memory management to put immovable
      allocations elsewhere.
      
      Implement simple detection of the bit for EFI memory table dumps and
      save the kernel policy for a follow-on change.
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      fe3e5e65
  16. 31 10月, 2019 1 次提交
  17. 29 10月, 2019 1 次提交
  18. 07 10月, 2019 1 次提交
    • A
      efivar/ssdt: Don't iterate over EFI vars if no SSDT override was specified · c05f8f92
      Ard Biesheuvel 提交于
      The kernel command line option efivar_ssdt= allows the name to be
      specified of an EFI variable containing an ACPI SSDT table that should
      be loaded into memory by the OS, and treated as if it was provided by
      the firmware.
      
      Currently, that code will always iterate over the EFI variables and
      compare each name with the provided name, even if the command line
      option wasn't set to begin with.
      
      So bail early when no variable name was provided. This works around a
      boot regression on the 2012 Mac Pro, as reported by Scott.
      Tested-by: NScott Talbert <swt@techie.net>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: <stable@vger.kernel.org> # v4.9+
      Cc: Ben Dooks <ben.dooks@codethink.co.uk>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Cc: Jerry Snitselaar <jsnitsel@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Lyude Paul <lyude@redhat.com>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: Octavian Purdila <octavian.purdila@intel.com>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Cc: linux-integrity@vger.kernel.org
      Fixes: 475fb4e8 ("efi / ACPI: load SSTDs from EFI variables")
      Link: https://lkml.kernel.org/r/20191002165904.8819-3-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c05f8f92
  19. 20 8月, 2019 1 次提交
  20. 08 8月, 2019 3 次提交