Skip to content

Commit 8993780

Browse files
author
Linus Torvalds
committed
Make SLES9 "get_kernel_version" work on the kernel binary again
As reported by Andy Whitcroft, at least the SLES9 initrd build process depends on getting the kernel version from the kernel binary. It does that by simply trawling the binary and looking for the signature of the "linux_banner" string (the string "Linux version " to be exact. Which is really broken in itself, but whatever..) That got broken when the string was changed to allow /proc/version to change the UTS release information dynamically, and "get_kernel_version" thus returned "%s" (see commit a2ee864: "[PATCH] Fix linux banner utsname information"). This just restores "linux_banner" as a static string, which should fix the version finding. And /proc/version simply uses a different string. To avoid wasting even that miniscule amount of memory, the early boot string should really be marked __initdata, but that just causes the same bug in SLES9 to re-appear, since it will then find other occurrences of "Linux version " first. Cc: Andy Whitcroft <apw@shadowen.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at> Cc: Andi Kleen <ak@suse.de> Cc: Andrew Morton <akpm@osdl.org> Cc: Steve Fox <drfickle@us.ibm.com> Acked-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 9202f32 commit 8993780

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

‎fs/proc/proc_misc.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <linux/vmalloc.h>
4848
#include <linux/crash_dump.h>
4949
#include <linux/pid_namespace.h>
50+
#include <linux/compile.h>
5051
#include <asm/uaccess.h>
5152
#include <asm/pgtable.h>
5253
#include <asm/io.h>
@@ -253,8 +254,15 @@ static int version_read_proc(char *page, char **start, off_t off,
253254
{
254255
int len;
255256

256-
len = sprintf(page, linux_banner,
257-
utsname()->release, utsname()->version);
257+
/* FIXED STRING! Don't touch! */
258+
len = snprintf(page, PAGE_SIZE,
259+
"%s version %s"
260+
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
261+
" (" LINUX_COMPILER ")"
262+
" %s\n",
263+
utsname()->sysname,
264+
utsname()->release,
265+
utsname()->version);
258266
return proc_calc_metrics(page, start, off, count, eof, len);
259267
}
260268

‎include/linux/kernel.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <asm/byteorder.h>
1818
#include <asm/bug.h>
1919

20-
extern const char linux_banner[];
21-
2220
#define INT_MAX ((int)(~0U>>1))
2321
#define INT_MIN (-INT_MAX - 1)
2422
#define UINT_MAX (~0U)

‎init/main.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ void __init __attribute__((weak)) smp_setup_processor_id(void)
483483
{
484484
}
485485

486+
static const char linux_banner[] =
487+
"Linux version " UTS_RELEASE
488+
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
489+
" (" LINUX_COMPILER ")"
490+
" " UTS_VERSION "\n";
491+
486492
asmlinkage void __init start_kernel(void)
487493
{
488494
char * command_line;
@@ -509,7 +515,7 @@ asmlinkage void __init start_kernel(void)
509515
boot_cpu_init();
510516
page_address_init();
511517
printk(KERN_NOTICE);
512-
printk(linux_banner, UTS_RELEASE, UTS_VERSION);
518+
printk(linux_banner);
513519
setup_arch(&command_line);
514520
unwind_setup();
515521
setup_per_cpu_areas();

‎init/version.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,3 @@ struct uts_namespace init_uts_ns = {
3333
},
3434
};
3535
EXPORT_SYMBOL_GPL(init_uts_ns);
36-
37-
const char linux_banner[] =
38-
"Linux version %s (" LINUX_COMPILE_BY "@"
39-
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") %s\n";
40-

0 commit comments

Comments
 (0)