diff mbox series

[v5,2/7] efi/libstub: Make initrd file loader configurable

Message ID 20200422172414.6662-3-ardb@kernel.org (mailing list archive)
State New, archived
Headers show
Series Add UEFI support for RISC-V | expand

Commit Message

Ard Biesheuvel April 22, 2020, 5:24 p.m. UTC
Loading an initrd passed via the kernel command line is deprecated: it
is limited to files that reside in the same volume as the one the kernel
itself was loaded from, and we have more flexible ways to achieve the
same. So make it configurable so new architectures can decide not to
enable it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/Kconfig        | 11 +++++++++++
 drivers/firmware/efi/libstub/file.c |  3 +++
 2 files changed, 14 insertions(+)

Comments

Geert Uytterhoeven June 16, 2020, 7:55 a.m. UTC | #1
Hi Ard,

On Wed, Apr 22, 2020 at 7:24 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> Loading an initrd passed via the kernel command line is deprecated: it
> is limited to files that reside in the same volume as the one the kernel
> itself was loaded from, and we have more flexible ways to achieve the
> same. So make it configurable so new architectures can decide not to
> enable it.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

Thanks for your patch, which is now commit cf6b83664895a5c7
("efi/libstub: Make initrd file loader configurable")!

> --- a/drivers/firmware/efi/Kconfig
> +++ b/drivers/firmware/efi/Kconfig
> @@ -124,6 +124,17 @@ config EFI_ARMSTUB_DTB_LOADER
>           functionality for bootloaders that do not have such support
>           this option is necessary.
>
> +config EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER
> +       bool "Enable the command line initrd loader"
> +       depends on EFI_GENERIC_STUB
> +       default y
> +       help
> +         Select this config option to add support for the initrd= command
> +         line parameter, allowing an initrd that resides on the same volume
> +         as the kernel image to be loaded into memory.
> +
> +         This method is deprecated.

So why the default y?

Gr{oetje,eeting}s,

                        Geert
Ard Biesheuvel June 16, 2020, 8:16 a.m. UTC | #2
On Tue, 16 Jun 2020 at 09:55, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ard,
>
> On Wed, Apr 22, 2020 at 7:24 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > Loading an initrd passed via the kernel command line is deprecated: it
> > is limited to files that reside in the same volume as the one the kernel
> > itself was loaded from, and we have more flexible ways to achieve the
> > same. So make it configurable so new architectures can decide not to
> > enable it.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> Thanks for your patch, which is now commit cf6b83664895a5c7
> ("efi/libstub: Make initrd file loader configurable")!
>
> > --- a/drivers/firmware/efi/Kconfig
> > +++ b/drivers/firmware/efi/Kconfig
> > @@ -124,6 +124,17 @@ config EFI_ARMSTUB_DTB_LOADER
> >           functionality for bootloaders that do not have such support
> >           this option is necessary.
> >
> > +config EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER
> > +       bool "Enable the command line initrd loader"
> > +       depends on EFI_GENERIC_STUB
> > +       default y
> > +       help
> > +         Select this config option to add support for the initrd= command
> > +         line parameter, allowing an initrd that resides on the same volume
> > +         as the kernel image to be loaded into memory.
> > +
> > +         This method is deprecated.
>
> So why the default y?
>

Hallo Geert,

Every time I try to disable something like this, someone pops out of
the woodwork to explain how the feature is so vitally important for
their highly bespoke and vertically integrated boot flow that it has
to be enabled by default for absolutely everybody.

But patches welcome :-)
diff mbox series

Patch

diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 2a2b2b96a1dc..4e788dd55b03 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -124,6 +124,17 @@  config EFI_ARMSTUB_DTB_LOADER
 	  functionality for bootloaders that do not have such support
 	  this option is necessary.
 
+config EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER
+	bool "Enable the command line initrd loader"
+	depends on EFI_GENERIC_STUB
+	default y
+	help
+	  Select this config option to add support for the initrd= command
+	  line parameter, allowing an initrd that resides on the same volume
+	  as the kernel image to be loaded into memory.
+
+	  This method is deprecated.
+
 config EFI_BOOTLOADER_CONTROL
 	tristate "EFI Bootloader Control"
 	depends on EFI_VARS
diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
index ea66b1f16a79..ccdc36aaaa97 100644
--- a/drivers/firmware/efi/libstub/file.c
+++ b/drivers/firmware/efi/libstub/file.c
@@ -254,6 +254,9 @@  efi_status_t efi_load_initrd(efi_loaded_image_t *image,
 			     unsigned long soft_limit,
 			     unsigned long hard_limit)
 {
+	if (!IS_ENABLED(CONFIG_EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER))
+		return EFI_SUCCESS;
+
 	return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2,
 				    soft_limit, hard_limit, load_addr, load_size);
 }