lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 18 Mar 2011 13:45:55 +0100
From:	Maximilian Schneider <not.m.schneider@...il.com>
To:	linux-kernel@...r.kernel.org
Subject: [PATCH] arch/x86/boot: added support for early builtin command-line

So far the builtin command-line was appended to the bootloader
supplied one in arch/x86/kernel/setup.c. Code executed before (e.g.
arch/x86/boot/*) would not access the builtin command-line and
therefore not react to parameters configuring the early setup (e.g.
earlyprintk).

---
 arch/x86/boot/boot.h |   30 ++++++++++++++++++++++++++++++
 arch/x86/boot/main.c |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index c7093bd..f3c6f9e 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -37,6 +37,7 @@

 extern struct setup_header hdr;
 extern struct boot_params boot_params;
+extern char builtin_cmd_line[];

 #define cpu_relax()    asm volatile("rep; nop")

@@ -289,12 +290,41 @@ int __cmdline_find_option(u32 cmdline_ptr, const
char *option, char *buffer, int
 int __cmdline_find_option_bool(u32 cmdline_ptr, const char *option);
 static inline int cmdline_find_option(const char *option, char
*buffer, int bufsize)
 {
+#ifdef CONFIG_CMDLINE_BOOL
+       u32 builtin_cmdline_ptr = (ds() << 4) + (u16)builtin_cmd_line;
+#ifdef CONFIG_CMDLINE_OVERRIDE
+       return __cmdline_find_option(builtin_cmdline_ptr, option,
buffer, bufsize);
+#else // !CONFIG_CMDLINE_OVERRIDE && CONFIG_CMDLINE_BOOL
+       int length_cmdline = __cmdline_find_option(boot_params.hdr.cmd_line_ptr,
+                        option, buffer, bufsize);
+       if (length_cmdline == -1) {
+               return __cmdline_find_option(builtin_cmdline_ptr,
option, buffer, bufsize);
+       } else {
+               return length_cmdline;
+       }
+#endif // CONFIG_CMDLINE_OVERRIDE
+#else // !CONFIG_CMDLINE_BOOL
        return __cmdline_find_option(boot_params.hdr.cmd_line_ptr,
option, buffer, bufsize);
+#endif
 }

 static inline int cmdline_find_option_bool(const char *option)
 {
+#ifdef CONFIG_CMDLINE_BOOL
+       u32 builtin_cmdline_ptr = (ds() << 4) + (u16)builtin_cmd_line;
+#ifdef CONFIG_CMDLINE_OVERRIDE
+       return __cmdline_find_option_bool(builtin_cmdline_ptr, option);
+#else // !CONFIG_CMDLINE_OVERRIDE && CONFIG_CMDLINE_BOOL
+       int length_cmdline =
__cmdline_find_option_bool(boot_params.hdr.cmd_line_ptr, option);
+       if (length_cmdline == -1) {
+               return __cmdline_find_option_bool(builtin_cmdline_ptr, option);
+       } else {
+               return length_cmdline;
+       }
+#endif // CONFIG_CMDLINE_OVERRIDE
+#else // !CONFIG_CMDLINE_BOOL
        return __cmdline_find_option_bool(boot_params.hdr.cmd_line_ptr, option);
+#endif
 }


diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 40358c8..9b12007 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -16,6 +16,7 @@
 #include "boot.h"

 struct boot_params boot_params __attribute__((aligned(16)));
+char builtin_cmd_line[] __attribute__((aligned(16))) = CONFIG_CMDLINE;

 char *HEAP = _end;
 char *heap_end = _end;         /* Default end of heap = no heap */
-- 
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ