mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Yinghai Lu <yinghai@kernel.org>,
	Gokul Caushik <caushik1@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Josh Triplett <josh@joshtriplett.org>
Subject: [PATCH] x86, boot: access cmdline when loaded high
Date: Tue, 11 Jun 2013 11:41:13 -0700	[thread overview]
Message-ID: <20130611184113.GA2288@www.outflux.net> (raw)

The __cmdline_find_option routine requires that the kernel cmdline be
located under 0x10000. When running the compressed boot code, if the
cmdline is loaded above this range, it will be ignored. This breaks
recognition of things like "earlyprintk=...". Since the compressed boot
code is already tricking the cmdline routines about locations, take it all
the way and access the cmdline via offset instead of via actual location.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/x86/boot/compressed/cmdline.c |   21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index bffd73b..2e39280 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -2,32 +2,29 @@
 
 #ifdef CONFIG_EARLY_PRINTK
 
+/*
+ * We know where the cmdline is, so just retain it, and use a non-zero
+ * offset to trick __cmdline_find_option into running.
+ */
 static unsigned long fs;
 static inline void set_fs(unsigned long seg)
 {
-	fs = seg << 4;  /* shift it back */
+	fs = real_mode->hdr.cmd_line_ptr;
+	fs |= (u64)real_mode->ext_cmd_line_ptr << 32;
 }
 typedef unsigned long addr_t;
 static inline char rdfs8(addr_t addr)
 {
-	return *((char *)(fs + addr));
+	return *((char *)(fs + addr - 0x1));
 }
 #include "../cmdline.c"
-static unsigned long get_cmd_line_ptr(void)
-{
-	unsigned long cmd_line_ptr = real_mode->hdr.cmd_line_ptr;
-
-	cmd_line_ptr |= (u64)real_mode->ext_cmd_line_ptr << 32;
-
-	return cmd_line_ptr;
-}
 int cmdline_find_option(const char *option, char *buffer, int bufsize)
 {
-	return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
+	return __cmdline_find_option(0x1, option, buffer, bufsize);
 }
 int cmdline_find_option_bool(const char *option)
 {
-	return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
+	return __cmdline_find_option_bool(0x1, option);
 }
 
 #endif
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

             reply	other threads:[~2013-06-11 18:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-11 18:41 Kees Cook [this message]
2013-06-11 19:17 ` Yinghai Lu
2013-06-11 19:26   ` Kees Cook
2013-06-11 20:54     ` Yinghai Lu
2013-06-11 20:59       ` Yinghai Lu
2013-06-13  0:05       ` Kees Cook

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=20130611184113.GA2288@www.outflux.net \
    --to=keescook@chromium.org \
    --cc=caushik1@gmail.com \
    --cc=hpa@zytor.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.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

all inboxes | Powered by JetHome®