1. 27 9月, 2022 3 次提交
  2. 07 1月, 2022 1 次提交
  3. 22 11月, 2021 1 次提交
  4. 19 8月, 2021 1 次提交
  5. 17 7月, 2021 1 次提交
  6. 17 9月, 2020 1 次提交
  7. 20 8月, 2020 3 次提交
  8. 13 7月, 2020 1 次提交
    • W
      efi/libstub/arm64: Retain 2MB kernel Image alignment if !KASLR · 7c116db2
      Will Deacon 提交于
      Since commit 82046702 ("efi/libstub/arm64: Replace 'preferred' offset
      with alignment check"), loading a relocatable arm64 kernel at a physical
      address which is not 2MB aligned and subsequently booting with EFI will
      leave the Image in-place, relying on the kernel to relocate itself early
      during boot. In conjunction with commit dd4bc607 ("arm64: warn on
      incorrect placement of the kernel by the bootloader"), which enables
      CONFIG_RELOCATABLE by default, this effectively means that entering an
      arm64 kernel loaded at an alignment smaller than 2MB with EFI (e.g. using
      QEMU) will result in silent relocation at runtime.
      
      Unfortunately, this has a subtle but confusing affect for developers
      trying to inspect the PC value during a crash and comparing it to the
      symbol addresses in vmlinux using tools such as 'nm' or 'addr2line';
      all text addresses will be displaced by a sub-2MB offset, resulting in
      the wrong symbol being identified in many cases. Passing "nokaslr" on
      the command line or disabling "CONFIG_RANDOMIZE_BASE" does not help,
      since the EFI stub only copies the kernel Image to a 2MB boundary if it
      is not relocatable.
      
      Adjust the EFI stub for arm64 so that the minimum Image alignment is 2MB
      unless KASLR is in use.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: David Brazdil <dbrazdil@google.com>
      Acked-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NWill Deacon <will@kernel.org>
      7c116db2
  9. 16 6月, 2020 1 次提交
  10. 22 5月, 2020 2 次提交
  11. 21 5月, 2020 5 次提交
  12. 19 5月, 2020 4 次提交
  13. 05 5月, 2020 1 次提交
  14. 01 5月, 2020 1 次提交
  15. 24 4月, 2020 4 次提交
  16. 24 2月, 2020 10 次提交
    • A
      efi/libstub/x86: Make loaded_image protocol handling mixed mode safe · f7b85b33
      Ard Biesheuvel 提交于
      Add the definitions and use the special wrapper so that the loaded_image
      UEFI protocol can be safely used from mixed mode.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      f7b85b33
    • A
      efi/libstub: Take noinitrd cmdline argument into account for devpath initrd · 79d3219d
      Ard Biesheuvel 提交于
      One of the advantages of using what basically amounts to a callback
      interface into the bootloader for loading the initrd is that it provides
      a natural place for the bootloader or firmware to measure the initrd
      contents while they are being passed to the kernel.
      
      Unfortunately, this is not a guarantee that the initrd will in fact be
      loaded and its /init invoked by the kernel, since the command line may
      contain the 'noinitrd' option, in which case the initrd is ignored, but
      this will not be reflected in the PCR that covers the initrd measurement.
      
      This could be addressed by measuring the command line as well, and
      including that PCR in the attestation policy, but this locks down the
      command line completely, which may be too restrictive.
      
      So let's take the noinitrd argument into account in the stub, too. This
      forces any PCR that covers the initrd to assume a different value when
      noinitrd is passed, allowing an attestation policy to disregard the
      command line if there is no need to take its measurement into account
      for other reasons.
      
      As Peter points out, this would still require the agent that takes the
      measurements to measure a separator event into the PCR in question at
      ExitBootServices() time, to prevent replay attacks using the known
      measurement from the TPM log.
      
      Cc: Peter Jones <pjones@redhat.com>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      79d3219d
    • A
      efi/libstub: Add support for loading the initrd from a device path · ec93fc37
      Ard Biesheuvel 提交于
      There are currently two ways to specify the initrd to be passed to the
      Linux kernel when booting via the EFI stub:
      - it can be passed as a initrd= command line option when doing a pure PE
        boot (as opposed to the EFI handover protocol that exists for x86)
      - otherwise, the bootloader or firmware can load the initrd into memory,
        and pass the address and size via the bootparams struct (x86) or
        device tree (ARM)
      
      In the first case, we are limited to loading from the same file system
      that the kernel was loaded from, and it is also problematic in a trusted
      boot context, given that we cannot easily protect the command line from
      tampering without either adding complicated white/blacklisting of boot
      arguments or locking down the command line altogether.
      
      In the second case, we force the bootloader to duplicate knowledge about
      the boot protocol which is already encoded in the stub, and which may be
      subject to change over time, e.g., bootparams struct definitions, memory
      allocation/alignment requirements for the placement of the initrd etc etc.
      In the ARM case, it also requires the bootloader to modify the hardware
      description provided by the firmware, as it is passed in the same file.
      On systems where the initrd is measured after loading, it creates a time
      window where the initrd contents might be manipulated in memory before
      handing over to the kernel.
      
      Address these concerns by adding support for loading the initrd into
      memory by invoking the EFI LoadFile2 protocol installed on a vendor
      GUIDed device path that specifically designates a Linux initrd.
      This addresses the above concerns, by putting the EFI stub in charge of
      placement in memory and of passing the base and size to the kernel proper
      (via whatever means it desires) while still leaving it up to the firmware
      or bootloader to obtain the file contents, potentially from other file
      systems than the one the kernel itself was loaded from. On platforms that
      implement measured boot, it permits the firmware to take the measurement
      right before the kernel actually consumes the contents.
      Acked-by: NLaszlo Ersek <lersek@redhat.com>
      Tested-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Acked-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      ec93fc37
    • A
      efi/libstub: Clean up command line parsing routine · 91d150c0
      Ard Biesheuvel 提交于
      We currently parse the command non-destructively, to avoid having to
      allocate memory for a copy before passing it to the standard parsing
      routines that are used by the core kernel, and which modify the input
      to delineate the parsed tokens with NUL characters.
      
      Instead, we call strstr() and strncmp() to go over the input multiple
      times, and match prefixes rather than tokens, which implies that we
      would match, e.g., 'nokaslrfoo' in the stub and disable KASLR, while
      the kernel would disregard the option and run with KASLR enabled.
      
      In order to avoid having to reason about whether and how this behavior
      may be abused, let's clean up the parsing routines, and rebuild them
      on top of the existing helpers.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      91d150c0
    • A
      efi/libstub: Move file I/O support code into separate file · 5193a33d
      Ard Biesheuvel 提交于
      Split off the file I/O support code into a separate source file so
      it ends up in a separate object file in the static library, allowing
      the linker to omit it if the routines are not used.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      5193a33d
    • A
      efi/libstub: Move get_dram_base() into arm-stub.c · b8717454
      Ard Biesheuvel 提交于
      get_dram_base() is only called from arm-stub.c so move it into
      the same source file as its caller.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      b8717454
    • A
      efi/libstub/x86: Permit cmdline data to be allocated above 4 GB · 1e45bf73
      Ard Biesheuvel 提交于
      We now support cmdline data that is located in memory that is not
      32-bit addressable, so relax the allocation limit on systems where
      this feature is enabled.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      1e45bf73
    • A
      efi/libstub: Use consistent type names for file I/O protocols · a46a290a
      Ard Biesheuvel 提交于
      Align the naming of efi_file_io_interface_t and efi_file_handle_t with
      the UEFI spec, and call them efi_simple_file_system_protocol_t and
      efi_file_protocol_t, respectively, using the same convention we use
      for all other type definitions that originate in the UEFI spec.
      
      While at it, move the definitions to efistub.h, so they are only seen
      by code that needs them.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      a46a290a
    • A
      efi/libstub: Simplify efi_high_alloc() and rename to efi_allocate_pages() · a7495c28
      Ard Biesheuvel 提交于
      The implementation of efi_high_alloc() uses a complicated way of
      traversing the memory map to find an available region that is located
      as close as possible to the provided upper limit, and calls AllocatePages
      subsequently to create the allocation at that exact address.
      
      This is precisely what the EFI_ALLOCATE_MAX_ADDRESS allocation type
      argument to AllocatePages() does, and considering that EFI_ALLOC_ALIGN
      only exceeds EFI_PAGE_SIZE on arm64, let's use AllocatePages() directly
      and implement the alignment using code that the compiler can remove if
      it does not exceed EFI_PAGE_SIZE.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      a7495c28
    • A
      efi/libstub: Move memory map handling and allocation routines to mem.c · f57db62c
      Ard Biesheuvel 提交于
      Create a new source file mem.c to keep the routines involved in memory
      allocation and deallocation and manipulation of the EFI memory map.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      f57db62c