public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] /proc/sys/kernel/bootloader_type
@ 2004-12-30  0:39 H. Peter Anvin
  2004-12-31  9:34 ` Andrew Morton
  2005-01-01 20:22 ` Kay Sievers
  0 siblings, 2 replies; 9+ messages in thread
From: H. Peter Anvin @ 2004-12-30  0:39 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, SYSLINUX

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

This patch exports to userspace the boot loader ID which has been 
exported by (b)zImage boot loaders since boot protocol version 2.

Tested on i386 and x86-64; as far as I know those are the only 
architectures which use zImage/bzImage format.

	-hpa


Signed-Off-By: H. Peter Anvin <hpa@zytor.com>


[-- Attachment #2: bootloader_type.patch --]
[-- Type: text/x-patch, Size: 4905 bytes --]

Index: linux-2.5/arch/i386/Makefile
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/arch/i386/Makefile,v
retrieving revision 1.73
diff -u -r1.73 Makefile
--- linux-2.5/arch/i386/Makefile	24 Dec 2004 21:09:54 -0000	1.73
+++ linux-2.5/arch/i386/Makefile	28 Dec 2004 04:56:17 -0000
@@ -20,6 +20,10 @@
 LDFLAGS_vmlinux :=
 CHECKFLAGS	+= -D__i386__
 
+# This allows compilation with an x86-64 compiler
+CC_M32		:= $(call cc-option,-m32)
+CC 		+= $(CC_M32)
+
 CFLAGS += -pipe -msoft-float
 
 # prevent gcc from keeping the stack 16 byte aligned
Index: linux-2.5/arch/i386/kernel/setup.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/arch/i386/kernel/setup.c,v
retrieving revision 1.128
diff -u -r1.128 setup.c
--- linux-2.5/arch/i386/kernel/setup.c	27 Dec 2004 18:21:04 -0000	1.128
+++ linux-2.5/arch/i386/kernel/setup.c	29 Dec 2004 22:10:30 -0000
@@ -97,6 +97,9 @@
 /* For PCI or other memory-mapped resources */
 unsigned long pci_mem_start = 0x10000000;
 
+/* Boot loader ID as an integer, for the benefit of proc_dointvec */
+int bootloader_type;
+
 /* user-defined highmem size */
 static unsigned int highmem_pages = -1;
 
@@ -1338,6 +1341,7 @@
 		BIOS_revision = SYS_DESC_TABLE.table[2];
 	}
 	aux_device_present = AUX_DEVICE_INFO;
+	bootloader_type = LOADER_TYPE;
 
 #ifdef CONFIG_BLK_DEV_RAM
 	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
Index: linux-2.5/arch/x86_64/kernel/setup.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/arch/x86_64/kernel/setup.c,v
retrieving revision 1.59
diff -u -r1.59 setup.c
--- linux-2.5/arch/x86_64/kernel/setup.c	2 Nov 2004 23:06:28 -0000	1.59
+++ linux-2.5/arch/x86_64/kernel/setup.c	29 Dec 2004 23:46:41 -0000
@@ -78,6 +78,9 @@
 /* For PCI or other memory-mapped resources */
 unsigned long pci_mem_start = 0x10000000;
 
+/* Boot loader ID as an integer, for the benefit of proc_dointvec */
+int bootloader_type;
+
 unsigned long saved_video_mode;
 
 #ifdef CONFIG_SWIOTLB
@@ -452,6 +455,7 @@
 	edid_info = EDID_INFO;
 	aux_device_present = AUX_DEVICE_INFO;
 	saved_video_mode = SAVED_VIDEO_MODE;
+	bootloader_type = LOADER_TYPE;
 
 #ifdef CONFIG_BLK_DEV_RAM
 	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
Index: linux-2.5/include/asm-i386/processor.h
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/include/asm-i386/processor.h,v
retrieving revision 1.78
diff -u -r1.78 processor.h
--- linux-2.5/include/asm-i386/processor.h	27 Dec 2004 18:21:04 -0000	1.78
+++ linux-2.5/include/asm-i386/processor.h	29 Dec 2004 23:45:34 -0000
@@ -283,6 +283,9 @@
 extern unsigned int BIOS_revision;
 extern unsigned int mca_pentium_flag;
 
+/* Boot loader type from the setup header */
+extern int bootloader_type;
+
 /*
  * User space process size: 3GB (default).
  */
Index: linux-2.5/include/asm-x86_64/processor.h
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/include/asm-x86_64/processor.h,v
retrieving revision 1.48
diff -u -r1.48 processor.h
--- linux-2.5/include/asm-x86_64/processor.h	27 Dec 2004 18:21:04 -0000	1.48
+++ linux-2.5/include/asm-x86_64/processor.h	29 Dec 2004 23:45:31 -0000
@@ -456,5 +456,7 @@
 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
 
 extern unsigned long boot_option_idle_override;
+/* Boot loader type from the setup header */
+extern int bootloader_type;
 
 #endif /* __ASM_X86_64_PROCESSOR_H */
Index: linux-2.5/include/linux/sysctl.h
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/include/linux/sysctl.h,v
retrieving revision 1.82
diff -u -r1.82 sysctl.h
--- linux-2.5/include/linux/sysctl.h	20 Oct 2004 15:36:36 -0000	1.82
+++ linux-2.5/include/linux/sysctl.h	29 Dec 2004 22:11:14 -0000
@@ -134,6 +134,7 @@
 	KERN_SPARC_SCONS_PWROFF=64, /* int: serial console power-off halt */
 	KERN_HZ_TIMER=65,	/* int: hz timer on or off */
 	KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */
+	KERN_BOOTLOADER_TYPE=67, /* int: boot loader type */
 };
 
 
Index: linux-2.5/kernel/sysctl.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/kernel/sysctl.c,v
retrieving revision 1.96
diff -u -r1.96 sysctl.c
--- linux-2.5/kernel/sysctl.c	2 Nov 2004 23:04:07 -0000	1.96
+++ linux-2.5/kernel/sysctl.c	29 Dec 2004 22:10:41 -0000
@@ -624,6 +624,16 @@
 		.proc_handler   = &proc_unknown_nmi_panic,
 	},
 #endif
+#if defined(CONFIG_X86)
+	{
+		.ctl_name	= KERN_BOOTLOADER_TYPE,
+		.procname	= "bootloader_type",
+		.data		= &bootloader_type,
+		.maxlen		= sizeof (int),
+		.mode		= 0444,
+		.proc_handler	= &proc_dointvec,
+	},
+#endif
 	{ .ctl_name = 0 }
 };
 

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH] /proc/sys/kernel/bootloader_type
@ 2005-01-01  9:39 Lethalman
  0 siblings, 0 replies; 9+ messages in thread
From: Lethalman @ 2005-01-01  9:39 UTC (permalink / raw)
  To: linux-kernel

(sorry for my poor English)
It's a nice idea and i think it shouldn't increase
the kernel size too much  ;)
Talking about security, if a possible attacker could know about the
bootloader type, he does nothing so this patch is not dangerous.
Good luck!

OT: a reply-to linux-kernel would be nice :/
(happy new year)

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

end of thread, other threads:[~2005-01-02  9:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-30  0:39 [PATCH] /proc/sys/kernel/bootloader_type H. Peter Anvin
2004-12-31  9:34 ` Andrew Morton
2004-12-31 10:12   ` Arjan van de Ven
2004-12-31 14:24     ` Coywolf Qi Hunt
2004-12-31 14:36       ` Arjan van de Ven
2004-12-31 20:10   ` H. Peter Anvin
2005-01-01 20:22 ` Kay Sievers
2005-01-02  8:56   ` Lethalman
  -- strict thread matches above, loose matches on Subject: below --
2005-01-01  9:39 Lethalman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox