mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
@ 2007-05-21 13:49 Hennerich, Michael
  2007-05-21 13:54 ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Hennerich, Michael @ 2007-05-21 13:49 UTC (permalink / raw)
  To: Pekka Enberg, Hennerich, Michael; +Cc: Bryan Wu, torvalds, akpm, linux-kernel

I'm also not an expert...
  
But without conswitchp preset (potential fix):

During initcalls: con_init is called, and returns because of
!display_desc.

static int __init con_init(void)
{
	const char *display_desc = NULL;
	struct vc_data *vc;
	unsigned int currcons = 0, i;

	acquire_console_sem();

	if (conswitchp)
		display_desc = conswitchp->con_startup();
	if (!display_desc) {
		fg_console = 0;
		release_console_sem();
		return 0; // RETURNS HERE
	}

--snip--

}

At this point there is no memory allocated for vc_cons[].d
A bit later vty_init calls kbd_init.

int __init vty_init(void)
{

--snip--
	kbd_init();
--snip--

}

>From now on events are passed to kbd_event which will then call
kbd_keycode.
I don't see where vc_cons[].d in between there is initialized.
 

>-----Original Message-----
>From: penberg@gmail.com [mailto:penberg@gmail.com] On Behalf Of Pekka
>Enberg
>Sent: Montag, 21. Mai 2007 14:51
>To: Hennerich, Michael
>Cc: Bryan Wu; torvalds@linux-foundation.org; akpm@linux-foundation.org;
>linux-kernel@vger.kernel.org
>Subject: Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard
>crashes kernel
>
>On 5/21/07, Hennerich, Michael <Michael.Hennerich@analog.com> wrote:
>> With CONFIG_VT (drivers/char/vt.c) enabled and a USB HID keyboard
>connected,
>> we were seeing bad pointer dereferences in drivers/char/keyboard.c
>>
>> In function kbd_keycode vc_cons[fg_console].d was un-initialized.
>
>On 5/21/07, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
>> Makes sense. Please consider adding this to the changelog. Thanks.
>
>I am not an expert on this, but I don't see how vc_cons[fg_console].d
>would be uninitialized. It is always set in
>drivers/char/vt.c:con_init() and drivers/char/vt.c:vc_allocate(). The
>conswitchp change affects vc->vc_sw but I don't see that being used in
>drivers/char/keyboard.c:kbd_keycode() except indirectly via
>set_console et al.
>
>Perhaps I am missing something here?

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

* Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
  2007-05-21 13:49 [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel Hennerich, Michael
@ 2007-05-21 13:54 ` Pekka Enberg
  0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2007-05-21 13:54 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: Bryan Wu, torvalds, akpm, linux-kernel

Hi Michael,

On 5/21/07, Hennerich, Michael <Michael.Hennerich@analog.com> wrote:
> During initcalls: con_init is called, and returns because of
> !display_desc.

[snip]

Aah, I missed that bit.

On 5/21/07, Hennerich, Michael <Michael.Hennerich@analog.com> wrote:
> I don't see where vc_cons[].d in between there is initialized.

Indeed. Your fix looks good. Thanks again for the explanation.

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

* Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
  2007-05-21 12:14 ` Pekka Enberg
@ 2007-05-21 12:50   ` Pekka Enberg
  0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2007-05-21 12:50 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: Bryan Wu, torvalds, akpm, linux-kernel

On 5/21/07, Hennerich, Michael <Michael.Hennerich@analog.com> wrote:
> With CONFIG_VT (drivers/char/vt.c) enabled and a USB HID keyboard connected,
> we were seeing bad pointer dereferences in drivers/char/keyboard.c
>
> In function kbd_keycode vc_cons[fg_console].d was un-initialized.

On 5/21/07, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> Makes sense. Please consider adding this to the changelog. Thanks.

I am not an expert on this, but I don't see how vc_cons[fg_console].d
would be uninitialized. It is always set in
drivers/char/vt.c:con_init() and drivers/char/vt.c:vc_allocate(). The
conswitchp change affects vc->vc_sw but I don't see that being used in
drivers/char/keyboard.c:kbd_keycode() except indirectly via
set_console et al.

Perhaps I am missing something here?

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

* Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
  2007-05-21 12:07 Hennerich, Michael
@ 2007-05-21 12:14 ` Pekka Enberg
  2007-05-21 12:50   ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2007-05-21 12:14 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: Bryan Wu, torvalds, akpm, linux-kernel

On 5/21/07, Hennerich, Michael <Michael.Hennerich@analog.com> wrote:
> I was fixing this issue some time ago.

[snip]

Makes sense. Please consider adding this to the changelog. Thanks.

                        Pekka

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

* RE: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
@ 2007-05-21 12:07 Hennerich, Michael
  2007-05-21 12:14 ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Hennerich, Michael @ 2007-05-21 12:07 UTC (permalink / raw)
  To: Pekka Enberg, Bryan Wu; +Cc: torvalds, akpm, linux-kernel, Michael Hennerich

I was fixing this issue some time ago.

With CONFIG_VT (drivers/char/vt.c) enabled and a USB HID keyboard connected, we were seeing bad pointer dereferences in drivers/char/keyboard.c

In function kbd_keycode vc_cons[fg_console].d was un-initialized .

static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
{
--snip--
	struct vc_data *vc = vc_cons[fg_console].d;

--snip--
	tty = vc->vc_tty;
--snip--
}	

The workaround, almost any arch does is to initialize conswitchp with the dummy console.

conswitchp = &dummy_con;	

The dummy console gets automatically selected if there is no other suitable console (VGA).
The bit we were missing is simply this fix.

Best regards,
Michael


------------------------------------------------------------------
********* Analog Devices GmbH         michael.hennerich@analog.com
**  *****                                      Systems Engineering
**     ** Wilhelm-Wagenfeld-Strasse 6       
**  ***** D-80807 Munich                      
********* Germany                          
Registergericht München HRB 40368,  Geschäftsführer:  Thomas Wessel, William A. Martin, Margaret Seif

>-----Original Message-----
>From: penberg@gmail.com [mailto:penberg@gmail.com] On Behalf Of Pekka
>Enberg
>Sent: Montag, 21. Mai 2007 13:40
>To: Bryan Wu
>Cc: torvalds@linux-foundation.org; akpm@linux-foundation.org; linux-
>kernel@vger.kernel.org; Michael Hennerich
>Subject: Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard
>crashes kernel
>
>Hi Bryan,
>
>On 5/21/07, Bryan Wu <bryan.wu@analog.com> wrote:
>> +#ifdef CONFIG_DUMMY_CONSOLE
>> +       conswitchp = &dummy_con;
>> +#endif
>>         cclk = get_cclk();
>>         sclk = get_sclk();
>
>This patch has no changelog. While it is probably apparent to you why
>this fixes a crash when using an USB keyboard, it would be nice for
>the rest of us to know which crash it fixes and why.

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

* Re: [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
  2007-05-21 10:09 ` [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel Bryan Wu
@ 2007-05-21 11:39   ` Pekka Enberg
  0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2007-05-21 11:39 UTC (permalink / raw)
  To: Bryan Wu; +Cc: torvalds, akpm, linux-kernel, Michael Hennerich

Hi Bryan,

On 5/21/07, Bryan Wu <bryan.wu@analog.com> wrote:
> +#ifdef CONFIG_DUMMY_CONSOLE
> +       conswitchp = &dummy_con;
> +#endif
>         cclk = get_cclk();
>         sclk = get_sclk();

This patch has no changelog. While it is probably apparent to you why
this fixes a crash when using an USB keyboard, it would be nice for
the rest of us to know which crash it fixes and why.

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

* [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel
  2007-05-21 10:09 [PATCH 00/32] Blackfin update for 2.6.22-rc2 Bryan Wu
@ 2007-05-21 10:09 ` Bryan Wu
  2007-05-21 11:39   ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Bryan Wu @ 2007-05-21 10:09 UTC (permalink / raw)
  To: torvalds, akpm, linux-kernel; +Cc: Michael Hennerich, Bryan Wu

From: Michael Hennerich <michael.hennerich@analog.com>

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---
 arch/blackfin/kernel/setup.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 342bb8d..c456ee5 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -33,7 +33,6 @@
 #include <linux/seq_file.h>
 #include <linux/cpu.h>
 #include <linux/module.h>
-#include <linux/console.h>
 #include <linux/tty.h>
 
 #include <linux/ext2_fs.h>
@@ -175,6 +174,9 @@ void __init setup_arch(char **cmdline_p)
 	unsigned long mtd_phys = 0;
 #endif
 
+#ifdef CONFIG_DUMMY_CONSOLE
+	conswitchp = &dummy_con;
+#endif
 	cclk = get_cclk();
 	sclk = get_sclk();
 
-- 
1.5.1.2

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

end of thread, other threads:[~2007-05-21 13:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-21 13:49 [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel Hennerich, Michael
2007-05-21 13:54 ` Pekka Enberg
  -- strict thread matches above, loose matches on Subject: below --
2007-05-21 12:07 Hennerich, Michael
2007-05-21 12:14 ` Pekka Enberg
2007-05-21 12:50   ` Pekka Enberg
2007-05-21 10:09 [PATCH 00/32] Blackfin update for 2.6.22-rc2 Bryan Wu
2007-05-21 10:09 ` [PATCH 12/32] Blackfin arch: Fix bug using usb keyboard crashes kernel Bryan Wu
2007-05-21 11:39   ` Pekka Enberg

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

all inboxes | Powered by JetHome®