* [PATCH 1/1] ensure we don't use bootconsoles after init has been released
@ 2007-08-20 2:46 Robin Getz
2007-08-20 3:11 ` Mike Frysinger
2007-08-22 3:14 ` [PATCH 1/1] fix - " Robin Getz
0 siblings, 2 replies; 10+ messages in thread
From: Robin Getz @ 2007-08-20 2:46 UTC (permalink / raw)
To: Andrew Morton; +Cc: torvalds, linux-kernel, Gerd Hoffmann
From: Robin Getz <rgetz@blackfin.uclinux.org>
This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511
This ensures that a bootconsole is unregistered if it is not replaced.
The current implementation spews garbage out the bootconsole in this case,
since the bootconsole structure is normally in the init section, and is
freed, but still used.
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
---
linux-2.6.x/kernel/printk.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: linux-2.6.x/kernel/printk.c
===================================================================
--- linux-2.6.x/kernel/printk.c
+++ linux-2.6.x/kernel/printk.c
@@ -1104,6 +1104,20 @@
}
EXPORT_SYMBOL(unregister_console);
+static int __init disable_boot_consoles(void)
+{
+ struct console *con;
+
+ for (con = console_drivers; con; con = con->next) {
+ if (con->flags & CON_BOOT) {
+ printk(KERN_INFO "Turn off boot console %s%d\n",
+ con->name, con->index);
+ unregister_console(con);
+ }
+ }
+}
+late_initcall(disable_boot_consoles);
+
/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 2:46 [PATCH 1/1] ensure we don't use bootconsoles after init has been released Robin Getz
@ 2007-08-20 3:11 ` Mike Frysinger
2007-08-20 3:31 ` Paul Mundt
2007-08-20 4:08 ` Robin Getz
2007-08-22 3:14 ` [PATCH 1/1] fix - " Robin Getz
1 sibling, 2 replies; 10+ messages in thread
From: Mike Frysinger @ 2007-08-20 3:11 UTC (permalink / raw)
To: Robin Getz; +Cc: Andrew Morton, torvalds, linux-kernel, Gerd Hoffmann
On 8/19/07, Robin Getz <rgetz@blackfin.uclinux.org> wrote:
> +static int __init disable_boot_consoles(void)
> +{
> + struct console *con;
> +
> + for (con = console_drivers; con; con = con->next) {
> + if (con->flags & CON_BOOT) {
> + printk(KERN_INFO "Turn off boot console %s%d\n",
> + con->name, con->index);
> + unregister_console(con);
> + }
> + }
> +}
erp, no 'return 0;' ... that'll earn you a warning at build time and
maybe random failures depending on the arch ...
-mike
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 3:11 ` Mike Frysinger
@ 2007-08-20 3:31 ` Paul Mundt
2007-08-20 17:14 ` Robin Getz
2007-08-20 19:22 ` Robin Getz
2007-08-20 4:08 ` Robin Getz
1 sibling, 2 replies; 10+ messages in thread
From: Paul Mundt @ 2007-08-20 3:31 UTC (permalink / raw)
To: Mike Frysinger
Cc: Robin Getz, Andrew Morton, torvalds, linux-kernel, Gerd Hoffmann
On Sun, Aug 19, 2007 at 11:11:47PM -0400, Mike Frysinger wrote:
> On 8/19/07, Robin Getz <rgetz@blackfin.uclinux.org> wrote:
> > +static int __init disable_boot_consoles(void)
> > +{
> > + struct console *con;
> > +
> > + for (con = console_drivers; con; con = con->next) {
> > + if (con->flags & CON_BOOT) {
> > + printk(KERN_INFO "Turn off boot console %s%d\n",
> > + con->name, con->index);
> > + unregister_console(con);
> > + }
> > + }
> > +}
>
> erp, no 'return 0;' ... that'll earn you a warning at build time and
> maybe random failures depending on the arch ...
Or better yet, complain if unregister_console() fails, and pass the
failure down.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 3:11 ` Mike Frysinger
2007-08-20 3:31 ` Paul Mundt
@ 2007-08-20 4:08 ` Robin Getz
1 sibling, 0 replies; 10+ messages in thread
From: Robin Getz @ 2007-08-20 4:08 UTC (permalink / raw)
To: Mike Frysinger
Cc: Andrew Morton, torvalds, linux-kernel, Gerd Hoffmann,
Mike Frysinger
From: Robin Getz <rgetz@blackfin.uclinux.org>
This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511
This ensures that a bootconsole is unregistered if it is not replaced.
The current implementation spews garbage out the bootconsole in this case,
since the bootconsole structure is normally in the init section, and is
freed, but still used.
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
---
linux-2.6.x-old/kernel/printk.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Index: linux-2.6.x-old/kernel/printk.c
===================================================================
--- linux-2.6.x-old/kernel/printk.c (revision 3583)
+++ linux-2.6.x-old/kernel/printk.c (working copy)
@@ -1104,6 +1104,21 @@
}
EXPORT_SYMBOL(unregister_console);
+static int __init disable_boot_consoles(void)
+{
+ struct console *con;
+
+ for (con = console_drivers; con; con = con->next) {
+ if (con->flags & CON_BOOT) {
+ printk(KERN_INFO "Turn off boot console %s%d\n",
+ con->name, con->index);
+ unregister_console(con);
+ }
+ }
+ return 0;
+}
+late_initcall(disable_boot_consoles);
+
/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 3:31 ` Paul Mundt
@ 2007-08-20 17:14 ` Robin Getz
2007-08-20 19:07 ` Gerd Hoffmann
2007-08-20 19:22 ` Robin Getz
1 sibling, 1 reply; 10+ messages in thread
From: Robin Getz @ 2007-08-20 17:14 UTC (permalink / raw)
To: Paul Mundt
Cc: Mike Frysinger, Andrew Morton, torvalds, linux-kernel,
Gerd Hoffmann
Try #3...
From: Robin Getz <rgetz@blackfin.uclinux.org>
This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511
This ensures that a bootconsole is unregistered if it is not replaced.
The current implementation spews garbage out the bootconsole in this case,
since the bootconsole structure is normally in the init section, and is
freed, but still used.
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
CC: Gerd Hoffmann <kraxel@redhat.com>
CC: Paul Mundt <lethal@linux-sh.org>
CC: Mike Frysinger <vapier.adi@gmail.com>
---
printk.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
Index: linux-2.6.x/kernel/printk.c
===================================================================
--- linux-2.6.x/kernel/printk.c
+++ linux-2.6.x/kernel/printk.c
@@ -1104,6 +1104,19 @@
}
EXPORT_SYMBOL(unregister_console);
+static int __init disable_boot_consoles(void)
+{
+ printk(KERN_INFO "here\n");
+
+ if (console_drivers->flags & CON_BOOT) {
+ printk(KERN_INFO "turn off boot console %s%d\n",
+ console_drivers->name, console_drivers->index);
+ return unregister_console(console_drivers);
+ }
+ return 0;
+}
+late_initcall(disable_boot_consoles);
+
/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 17:14 ` Robin Getz
@ 2007-08-20 19:07 ` Gerd Hoffmann
0 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2007-08-20 19:07 UTC (permalink / raw)
To: Robin Getz
Cc: Paul Mundt, Mike Frysinger, Andrew Morton, torvalds, linux-kernel
Robin Getz wrote:
> Try #3...
>
> From: Robin Getz <rgetz@blackfin.uclinux.org>
> +static int __init disable_boot_consoles(void)
> +{
> + printk(KERN_INFO "here\n");
leftover debug printk?
cheers,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 3:31 ` Paul Mundt
2007-08-20 17:14 ` Robin Getz
@ 2007-08-20 19:22 ` Robin Getz
2007-08-20 19:26 ` Gerd Hoffmann
2007-08-20 22:47 ` Paul Mundt
1 sibling, 2 replies; 10+ messages in thread
From: Robin Getz @ 2007-08-20 19:22 UTC (permalink / raw)
To: Andrew Morton, torvalds
Cc: Paul Mundt, Mike Frysinger, linux-kernel, Gerd Hoffmann
Try #4... (sorry)
From: Robin Getz <rgetz@blackfin.uclinux.org>
This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511
This ensures that a bootconsole is unregistered if it is not replaced.
The current implementation spews garbage out the bootconsole in this case,
since the bootconsole structure is normally in the init section, and is
freed, but still used.
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
CC: Gerd Hoffmann <kraxel@redhat.com>
CC: Paul Mundt <lethal@linux-sh.org>
CC: Mike Frysinger <vapier.adi@gmail.com>
---
kernel/printk.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Index: linux-2.6.x/kernel/printk.c
===================================================================
--- linux-2.6.x/kernel/printk.c (revision 3583)
+++ linux-2.6.x/kernel/printk.c (working copy)
@@ -1104,6 +1104,17 @@
}
EXPORT_SYMBOL(unregister_console);
+static int __init disable_boot_consoles(void)
+{
+ if (console_drivers->flags & CON_BOOT) {
+ printk(KERN_INFO "turn off boot console %s%d\n",
+ console_drivers->name, console_drivers->index);
+ return unregister_console(console_drivers);
+ }
+ return 0;
+}
+late_initcall(disable_boot_consoles);
+
/**
* tty_write_message - write a message to a certain tty, not just the console.
* @tty: the destination tty_struct
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 19:22 ` Robin Getz
@ 2007-08-20 19:26 ` Gerd Hoffmann
2007-08-20 22:47 ` Paul Mundt
1 sibling, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2007-08-20 19:26 UTC (permalink / raw)
To: Robin Getz
Cc: Andrew Morton, torvalds, Paul Mundt, Mike Frysinger, linux-kernel
Robin Getz wrote:
> This ensures that a bootconsole is unregistered if it is not replaced.
> The current implementation spews garbage out the bootconsole in this case,
> since the bootconsole structure is normally in the init section, and is
> freed, but still used.
>
> Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
> CC: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
cheers,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] ensure we don't use bootconsoles after init has been released
2007-08-20 19:22 ` Robin Getz
2007-08-20 19:26 ` Gerd Hoffmann
@ 2007-08-20 22:47 ` Paul Mundt
1 sibling, 0 replies; 10+ messages in thread
From: Paul Mundt @ 2007-08-20 22:47 UTC (permalink / raw)
To: Robin Getz
Cc: Andrew Morton, torvalds, Mike Frysinger, linux-kernel,
Gerd Hoffmann
On Mon, Aug 20, 2007 at 03:22:47PM -0400, Robin Getz wrote:
> Try #4... (sorry)
>
> From: Robin Getz <rgetz@blackfin.uclinux.org>
>
> This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511
>
> This ensures that a bootconsole is unregistered if it is not replaced.
> The current implementation spews garbage out the bootconsole in this case,
> since the bootconsole structure is normally in the init section, and is
> freed, but still used.
>
> Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> CC: Paul Mundt <lethal@linux-sh.org>
> CC: Mike Frysinger <vapier.adi@gmail.com>
Looks better, thanks.
Acked-by: Paul Mundt <lethal@linux-sh.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/1] fix - ensure we don't use bootconsoles after init has been released
2007-08-20 2:46 [PATCH 1/1] ensure we don't use bootconsoles after init has been released Robin Getz
2007-08-20 3:11 ` Mike Frysinger
@ 2007-08-22 3:14 ` Robin Getz
1 sibling, 0 replies; 10+ messages in thread
From: Robin Getz @ 2007-08-22 3:14 UTC (permalink / raw)
To: Andrew Morton
Cc: torvalds, linux-kernel, Gerd Hoffmann, Paul Mundt, Mike Frysinger
From: Robin Getz <rgetz@blackfin.uclinux.org>
Gerd Hoffmann pointed out that my patch from yesterday can lead
to a null pointer dereference if the kernel is booted with no
console, and no earlyprintk defined. This fixes that issue.
printk.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
---
Index: linux-2.6.x/kernel/printk.c
===================================================================
--- linux-2.6.x/kernel/printk.c
+++ linux-2.6.x/kernel/printk.c
@@ -1106,10 +1106,12 @@
static int __init disable_boot_consoles(void)
{
- if (console_drivers->flags & CON_BOOT) {
- printk(KERN_INFO "turn off boot console %s%d\n",
- console_drivers->name, console_drivers->index);
- return unregister_console(console_drivers);
+ if (console_drivers != NULL) {
+ if (console_drivers->flags & CON_BOOT) {
+ printk(KERN_INFO "turn off boot console %s%d\n",
+ console_drivers->name, console_drivers->index);
+ return unregister_console(console_drivers);
+ }
}
return 0;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-08-22 3:15 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-20 2:46 [PATCH 1/1] ensure we don't use bootconsoles after init has been released Robin Getz
2007-08-20 3:11 ` Mike Frysinger
2007-08-20 3:31 ` Paul Mundt
2007-08-20 17:14 ` Robin Getz
2007-08-20 19:07 ` Gerd Hoffmann
2007-08-20 19:22 ` Robin Getz
2007-08-20 19:26 ` Gerd Hoffmann
2007-08-20 22:47 ` Paul Mundt
2007-08-20 4:08 ` Robin Getz
2007-08-22 3:14 ` [PATCH 1/1] fix - " Robin Getz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox