1. 21 5月, 2020 2 次提交
  2. 19 5月, 2020 3 次提交
  3. 05 5月, 2020 2 次提交
  4. 01 5月, 2020 3 次提交
  5. 24 4月, 2020 11 次提交
  6. 14 4月, 2020 1 次提交
  7. 24 2月, 2020 14 次提交
    • A
      efi/libstub/x86: Use Exit() boot service to exit the stub on errors · 3b8f44fc
      Ard Biesheuvel 提交于
      Currently, we either return with an error [from efi_pe_entry()] or
      enter a deadloop [in efi_main()] if any fatal errors occur during
      execution of the EFI stub. Let's switch to calling the Exit() EFI boot
      service instead in both cases, so that we
      a) can get rid of the deadloop, and simply return to the boot manager
         if any errors occur during execution of the stub, including during
         the call to ExitBootServices(),
      b) can also return cleanly from efi_pe_entry() or efi_main() in mixed
         mode, once we introduce support for LoadImage/StartImage based mixed
         mode in the next patch.
      
      Note that on systems running downstream GRUBs [which do not use LoadImage
      or StartImage to boot the kernel, and instead, pass their own image
      handle as the loaded image handle], calling Exit() will exit from GRUB
      rather than from the kernel, but this is a tolerable side effect.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      3b8f44fc
    • 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: Make the LoadFile EFI protocol accessible · 2931d526
      Ard Biesheuvel 提交于
      Add the protocol definitions, GUIDs and mixed mode glue so that
      the EFI loadfile protocol can be used from the stub. This will
      be used in a future patch to load the initrd.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      2931d526
    • A
      efi/libstub: Expose LocateDevicePath boot service · abd26868
      Ard Biesheuvel 提交于
      We will be adding support for loading the initrd from a GUIDed
      device path in a subsequent patch, so update the prototype of
      the LocateDevicePath() boot service to make it callable from
      our code.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      abd26868
    • A
      efi/libstub: Take soft and hard memory limits into account for initrd loading · 31f5e546
      Ard Biesheuvel 提交于
      On x86, the preferred load address of the initrd is still below 4 GB,
      even though in some cases, we can cope with an initrd that is loaded
      above that.
      
      To simplify the code, and to make it more straightforward to introduce
      other ways to load the initrd, pass the soft and hard memory limits at
      the same time, and let the code handling the initrd= command line option
      deal with this.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      31f5e546
    • A
      efi/libstub: Rewrite file I/O routine · 9302c1bb
      Ard Biesheuvel 提交于
      The file I/O routine that is used to load initrd or dtb files from
      the EFI system partition suffers from a few issues:
      - it converts the u8[] command line back to a UTF-16 string, which is
        pointless since we only handle initrd or dtb arguments provided via
        the loaded image protocol anyway, which is where we got the UTF-16[]
        command line from in the first place when booting via the PE entry
        point,
      - in the far majority of cases, only a single initrd= option is present,
        but it optimizes for multiple options, by going over the command line
        twice, allocating heap buffers for dynamically sized arrays, etc.
      - the coding style is hard to follow, with few comments, and all logic
        including string parsing etc all combined in a single routine.
      
      Let's fix this by rewriting most of it, based on the idea that in the
      case of multiple initrds, we can just allocate a new, bigger buffer
      and copy over the data before freeing the old one.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      9302c1bb
    • 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: Move stub specific declarations into efistub.h · 8166ec09
      Ard Biesheuvel 提交于
      Move all the declarations that are only used in stub code from
      linux/efi.h to efistub.h which is only included locally.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      8166ec09
    • 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/x86: Incorporate eboot.c into libstub · c2d0b470
      Ard Biesheuvel 提交于
      Most of the EFI stub source files of all architectures reside under
      drivers/firmware/efi/libstub, where they share a Makefile with special
      CFLAGS and an include file with declarations that are only relevant
      for stub code.
      
      Currently, we carry a lot of stub specific stuff in linux/efi.h only
      because eboot.c in arch/x86 needs them as well. So let's move eboot.c
      into libstub/, and move the contents of eboot.h that we still care
      about into efistub.h
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      c2d0b470
  8. 25 12月, 2019 4 次提交