linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Sverdlin <asv@sysgo.com>
To: torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] init: Carefuly handle loglevel option passed to kernel cmdline
Date: Wed, 21 Sep 2011 09:51:40 +0200	[thread overview]
Message-ID: <1316591500.14570.7.camel@alex-vb> (raw)

From: Alexander Sverdlin <alexander.sverdlin@sysgo.com>

Carefuly handle loglevel option passed to kernel cmdline.

When malformed loglevel value (for example "${abc}") passed to kernel
cmdline, the loglevel itself is being set to 0. This suppresses all
following messages, including all the errors and crashes caused by
other malformed cmdline options. This could make debugging process
quite tricky. Provided modifications leaves previous value of loglevel
if the new value is incorrect and report error code in this case.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@sysgo.com>
---
--- linux.old/init/main.c	2011-09-20 15:23:05.038279428 +0200
+++ linux/init/main.c	2011-09-21 09:39:24.266516051 +0200
@@ -209,8 +209,19 @@ early_param("quiet", quiet_kernel);
 
 static int __init loglevel(char *str)
 {
-	get_option(&str, &console_loglevel);
-	return 0;
+	int tmp_loglevel;
+
+	/*
+	 * Only update loglevel value when correct setting was passed,
+	 * to prevent blind crashes (when loglevel being set to 0) that
+	 * are quite hard to debug
+	 */
+	if (get_option(&str, &tmp_loglevel)) {
+		console_loglevel = tmp_loglevel;
+		return 0;
+	}
+
+	return -EINVAL;
 }
 
 early_param("loglevel", loglevel);




             reply	other threads:[~2011-09-21  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21  7:51 Alexander Sverdlin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-09-20 13:45 [PATCH] init: Carefuly handle loglevel option passed to kernel cmdline Alexander Sverdlin
2011-09-20 14:56 ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316591500.14570.7.camel@alex-vb \
    --to=asv@sysgo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).