linux-kernel.vger.kernel.org archive mirror
 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
  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 20:10   ` H. Peter Anvin
  2005-01-01 20:22 ` Kay Sievers
  1 sibling, 2 replies; 9+ messages in thread
From: Andrew Morton @ 2004-12-31  9:34 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel, SYSLINUX

"H. Peter Anvin" <hpa@zytor.com> wrote:
>
> This patch exports to userspace the boot loader ID which has been 
>  exported by (b)zImage boot loaders since boot protocol version 2.

Why does userspace need to know this?

>  --- 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)

Was this hunk deliberately a part of this patch?

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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  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 20:10   ` H. Peter Anvin
  1 sibling, 1 reply; 9+ messages in thread
From: Arjan van de Ven @ 2004-12-31 10:12 UTC (permalink / raw)
  To: Andrew Morton; +Cc: H. Peter Anvin, linux-kernel, SYSLINUX

On Fri, 2004-12-31 at 01:34 -0800, Andrew Morton wrote:
> "H. Peter Anvin" <hpa@zytor.com> wrote:
> >
> > This patch exports to userspace the boot loader ID which has been 
> >  exported by (b)zImage boot loaders since boot protocol version 2.
> 
> Why does userspace need to know this?

so that update tools that update kernels from vendors know which
bootloader file they need to update; eg right now those tools do all
kinds of hairy heuristics to find out if it's grub or lilo or .. that
installed the kernel. Those heuristics are fragile in the presence of
more than one bootloader (which isn't that uncommon in OS upgrade
situations).



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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Coywolf Qi Hunt @ 2004-12-31 14:24 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: Andrew Morton, H. Peter Anvin, linux-kernel, SYSLINUX

On Fri, 31 Dec 2004 11:12:34 +0100, Arjan van de Ven
<arjan@infradead.org> wrote:
> On Fri, 2004-12-31 at 01:34 -0800, Andrew Morton wrote:
> > "H. Peter Anvin" <hpa@zytor.com> wrote:
> > >
> > > This patch exports to userspace the boot loader ID which has been
> > >  exported by (b)zImage boot loaders since boot protocol version 2.
> >
> > Why does userspace need to know this?
> 
> so that update tools that update kernels from vendors know which
> bootloader file they need to update; eg right now those tools do all
> kinds of hairy heuristics to find out if it's grub or lilo or .. that
> installed the kernel. Those heuristics are fragile in the presence of
> more than one bootloader (which isn't that uncommon in OS upgrade
> situations).
> 

This boot loader ID doesn't help much for system upgrade. The running
kernel may boot from removable drive.


-- 
Coywolf Qi Hunt
Homepage http://sosdg.org/~coywolf/

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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  2004-12-31 14:24     ` Coywolf Qi Hunt
@ 2004-12-31 14:36       ` Arjan van de Ven
  0 siblings, 0 replies; 9+ messages in thread
From: Arjan van de Ven @ 2004-12-31 14:36 UTC (permalink / raw)
  To: Coywolf Qi Hunt; +Cc: Andrew Morton, H. Peter Anvin, linux-kernel, SYSLINUX

On Fri, 2004-12-31 at 22:24 +0800, Coywolf Qi Hunt wrote:
> On Fri, 31 Dec 2004 11:12:34 +0100, Arjan van de Ven
> <arjan@infradead.org> wrote:
> > On Fri, 2004-12-31 at 01:34 -0800, Andrew Morton wrote:
> > > "H. Peter Anvin" <hpa@zytor.com> wrote:
> > > >
> > > > This patch exports to userspace the boot loader ID which has been
> > > >  exported by (b)zImage boot loaders since boot protocol version 2.
> > >
> > > Why does userspace need to know this?
> > 
> > so that update tools that update kernels from vendors know which
> > bootloader file they need to update; eg right now those tools do all
> > kinds of hairy heuristics to find out if it's grub or lilo or .. that
> > installed the kernel. Those heuristics are fragile in the presence of
> > more than one bootloader (which isn't that uncommon in OS upgrade
> > situations).
> > 
> 
> This boot loader ID doesn't help much for system upgrade. The running
> kernel may boot from removable drive.

but then it says syslinux or so... 
means that the lilo-or-grub question still needs the heuristics, it's
just that in the normal case, the bootloader type can help make the
heuristics reliable.



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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  2004-12-31  9:34 ` Andrew Morton
  2004-12-31 10:12   ` Arjan van de Ven
@ 2004-12-31 20:10   ` H. Peter Anvin
  1 sibling, 0 replies; 9+ messages in thread
From: H. Peter Anvin @ 2004-12-31 20:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, SYSLINUX

Andrew Morton wrote:
> "H. Peter Anvin" <hpa@zytor.com> wrote:
> 
>>This patch exports to userspace the boot loader ID which has been 
>> exported by (b)zImage boot loaders since boot protocol version 2.
> 
> Why does userspace need to know this?
> 

In order to try to figure out what the boot medium was.  For some boot 
loaders, like grub, it could be more or less anything, but others, e.g. 
syslinux, knowing what the boot loader is lets you know what the medium was.

> 
>> --- 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)
> 
> 
> Was this hunk deliberately a part of this patch?

No, that was a separate patch I submitted several weeks ago which was 
apparently still in that tree.  Would be good to get that patch into the 
tree, though; it allows an x86-64 setup to compile an i386 kernel with 
only make ARCH=i386.

	-hpa

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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  2004-12-30  0:39 [PATCH] /proc/sys/kernel/bootloader_type H. Peter Anvin
  2004-12-31  9:34 ` Andrew Morton
@ 2005-01-01 20:22 ` Kay Sievers
  2005-01-02  8:56   ` Lethalman
  1 sibling, 1 reply; 9+ messages in thread
From: Kay Sievers @ 2005-01-01 20:22 UTC (permalink / raw)
  To: linux-kernel

H. Peter Anvin <hpa <at> zytor.com> writes:

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

Isn't /sys/kernel/bootloader_type a better place than /proc for new values?

Thanks,
Kay


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

* Re: [PATCH] /proc/sys/kernel/bootloader_type
  2005-01-01 20:22 ` Kay Sievers
@ 2005-01-02  8:56   ` Lethalman
  0 siblings, 0 replies; 9+ messages in thread
From: Lethalman @ 2005-01-02  8:56 UTC (permalink / raw)
  To: linux-kernel

Kay Sievers wrote:
> H. Peter Anvin <hpa <at> zytor.com> writes:
> 
> 
>>This patch exports to userspace the boot loader ID which has been 
>>exported by (b)zImage boot loaders since boot protocol version 2.
> 
> 
> Isn't /sys/kernel/bootloader_type a better place than /proc for new values?
> 
> Thanks,
> Kay
> 

In fact it's stored in /proc/sys/kernel/bootloader_type as sysctl does...

^ 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
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;
as well as URLs for NNTP newsgroup(s).