linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] init: Disable defaults if init= fails
@ 2014-09-29  2:40 Andy Lutomirski
  2014-09-30 12:12 ` Chuck Ebbert
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Andy Lutomirski @ 2014-09-29  2:40 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Chuck Ebbert, Rob Landley, Randy Dunlap, Shuah Khan,
	Rusty Russell, Andy Lutomirski

If a user puts init=/whatever on the command line and /whatever
can't be run, then the kernel will try a few default options before
giving up.  If init=/whatever came from a bootloader prompt, then
this is unexpected but probably harmless.  On the other hand, if it
comes from a script (e.g. a tool like virtme or perhaps a future
kselftest script), then the fallbacks are likely to exist, but
they'll do the wrong thing.  For example, they might unexpectedly
invoke systemd.

This makes a failure to run the specified init= process be fatal.

As a temporary measure, users can set CONFIG_INIT_FALLBACK=y to
preserve the old behavior.  If no one speaks up, we can remove that
option entirely after a release or two.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---

Changes from v4:
 - Update the panic message (sorry for the noise)

Changes from v3:
 - Get rid of the strictinit option.  Now the new behavior is the default
   unless CONFIG_INIT_FALLBACK=y (Rob Landley)

Changes from v2:
 - Improve docs further, to leave the door open to giving strictinit
   some sensible semantics if init= is not set.
 - Improve error output in the failure case (Shuah Khan).

Changes from v1:
 - Add missing "if" to the docs (Randy Dunlap)

 init/Kconfig | 11 +++++++++++
 init/main.c  |  7 ++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index e84c6423a2e5..063029a1556f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1299,6 +1299,17 @@ source "usr/Kconfig"
 
 endif
 
+config INIT_FALLBACK
+	bool "Fall back to defaults if init= parameter is bad"
+	help
+	  If enabled, the kernel will try the default init binaries if an
+	  explicit request from the init= parameter fails.
+
+	  This is a temporary measure to allow broken configurations
+	  to continue to boot.
+
+	  If unsure, say N.
+
 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size"
 	help
diff --git a/init/main.c b/init/main.c
index bb1aed928f21..2bd6105e5dc5 100644
--- a/init/main.c
+++ b/init/main.c
@@ -960,8 +960,13 @@ static int __ref kernel_init(void *unused)
 		ret = run_init_process(execute_command);
 		if (!ret)
 			return 0;
+#ifndef CONFIG_INIT_FALLBACK
+		panic("Requested init %s failed (error %d).",
+		      execute_command, ret);
+#else
 		pr_err("Failed to execute %s (error %d).  Attempting defaults...\n",
-			execute_command, ret);
+		       execute_command, ret);
+#endif
 	}
 	if (!try_to_run_init_process("/sbin/init") ||
 	    !try_to_run_init_process("/etc/init") ||
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2014-10-21 10:05 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-29  2:40 [PATCH v5] init: Disable defaults if init= fails Andy Lutomirski
2014-09-30 12:12 ` Chuck Ebbert
2014-10-01  0:41 ` Frank Rowand
2014-10-01  0:58   ` Rob Landley
2014-10-01  1:52     ` Frank Rowand
2014-10-01  3:16       ` Rob Landley
2014-10-01  4:53         ` Andy Lutomirski
2014-10-01 18:05           ` josh
2014-10-01 18:13             ` Andy Lutomirski
2014-10-01 22:42               ` josh
2014-10-14 21:00               ` Andrew Morton
2014-10-14 21:21                 ` Andy Lutomirski
2014-10-15  5:46                   ` Frank Rowand
2014-10-15  5:56                     ` Andy Lutomirski
2014-10-15  6:37                       ` Frank Rowand
2014-10-15 15:18                 ` Rob Landley
2014-10-20 20:14                 ` Andy Lutomirski
2014-10-20 21:01                   ` Josh Triplett
2014-10-20 21:28                     ` Andrew Morton
2014-10-20 21:34                       ` Andy Lutomirski
2014-10-20 21:41                         ` Andrew Morton
2014-10-20 21:42                           ` Andy Lutomirski
2014-10-20 21:44                             ` Andrew Morton
2014-10-20 22:04                               ` [PATCH] init: Remove CONFIG_INIT_FALLBACK Andy Lutomirski
2014-10-20 22:06                                 ` josh
2014-10-21  3:45                                 ` Rob Landley
2014-10-21  4:02                                   ` Andy Lutomirski
2014-10-21  4:15                                     ` Rob Landley
2014-10-21  9:53                                 ` Geert Uytterhoeven
2014-10-21 10:05                                   ` Josh Triplett
2014-10-14  0:47 ` [PATCH v5] init: Disable defaults if init= fails Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).