Commit cff75e0b6fe835800f8e08a32d731119cd9e3b79

Authored by Daniel Thompson
Committed by Linus Torvalds
1 parent da5e108b02

initramfs: provide a way to ignore image provided by bootloader

Many "embedded" architectures provide CMDLINE_FORCE to allow the kernel
to override the command line provided by an inflexible bootloader.
However there is currrently no way for the kernel to override the
initramfs image provided by the bootloader meaning there are still ways
for bootloaders to make things difficult for us.

Fix this by introducing INITRAMFS_FORCE which can prevent the kernel
from loading the bootloader supplied image.

We use CMDLINE_FORCE (and its friend CMDLINE_EXTEND) to imply that the
system has an inflexible bootloader.  This allow us to avoid presenting
this config option to users of systems where inflexible bootloaders
aren't usually a problem.

Link: http://lkml.kernel.org/r/20170217121940.30126-1-daniel.thompson@linaro.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 11 additions and 1 deletions Side-by-side Diff

... ... @@ -613,7 +613,7 @@
613 613 if (err)
614 614 panic("%s", err); /* Failed to decompress INTERNAL initramfs */
615 615 /* If available load the bootloader supplied initrd */
616   - if (initrd_start) {
  616 + if (initrd_start && !IS_ENABLED(CONFIG_INITRAMFS_FORCE)) {
617 617 #ifdef CONFIG_BLK_DEV_RAM
618 618 int fd;
619 619 printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
... ... @@ -21,6 +21,16 @@
21 21  
22 22 If you are not sure, leave it blank.
23 23  
  24 +config INITRAMFS_FORCE
  25 + bool "Ignore the initramfs passed by the bootloader"
  26 + depends on CMDLINE_EXTEND || CMDLINE_FORCE
  27 + help
  28 + This option causes the kernel to ignore the initramfs image
  29 + (or initrd image) passed to it by the bootloader. This is
  30 + analogous to CMDLINE_FORCE, which is found on some architectures,
  31 + and is useful if you cannot or don't want to change the image
  32 + your bootloader passes to the kernel.
  33 +
24 34 config INITRAMFS_ROOT_UID
25 35 int "User ID to map to 0 (user root)"
26 36 depends on INITRAMFS_SOURCE!=""