Skip to content

Commit

Permalink
initramfs: provide a way to ignore image provided by bootloader
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Daniel Thompson <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
daniel-thompson authored and hnaz committed Mar 10, 2017
1 parent 66fe49e commit d21c999
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ static int __init populate_rootfs(void)
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
if (err)
panic("%s", err); /* Failed to decompress INTERNAL initramfs */
if (initrd_start) {
if (initrd_start && !IS_ENABLED(CONFIG_INITRAMFS_FORCE)) {
#ifdef CONFIG_BLK_DEV_RAM
int fd;
printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
Expand Down
10 changes: 10 additions & 0 deletions usr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ config INITRAMFS_SOURCE

If you are not sure, leave it blank.

config INITRAMFS_FORCE
bool "Ignore the initramfs passed by the bootloader"
depends on CMDLINE_EXTEND || CMDLINE_FORCE
help
This option causes the kernel to ignore the initramfs image
(or initrd image) passed to it by the bootloader. This is
analogous to CMDLINE_FORCE, which is found on some architectures,
and is useful if you cannot or don't want to change the image
your bootloader passes to the kernel.

config INITRAMFS_ROOT_UID
int "User ID to map to 0 (user root)"
depends on INITRAMFS_SOURCE!=""
Expand Down

0 comments on commit d21c999

Please sign in to comment.