public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
@ 2007-01-25 18:06 Bernhard Walle
  2007-01-27  6:28 ` Jes Sorensen
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bernhard Walle @ 2007-01-25 18:06 UTC (permalink / raw)
  To: linux-ia64

This patch fixes a NULL-pointer dereference in ia64_machine_kexec().

The variable ia64_kimage is set in machine_kexec_prepare() which is called
from sys_kexec_load(). If kdump wasn't configured before, ia64_kimage is NULL.
machine_kdump_on_init() passes ia64_kimage() to machine_kexec() which assumes
a valid value.

The patch also adds a few sanity checks for the image to simplify debugging of
similar problems in future.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Acked-by: Raymund Will <rw@suse.de>

---
 arch/ia64/kernel/crash.c         |    4 ++++
 arch/ia64/kernel/machine_kexec.c |    2 ++
 2 files changed, 6 insertions(+)

Index: current-kernel/arch/ia64/kernel/crash.c
=================================--- current-kernel.orig/arch/ia64/kernel/crash.c
+++ current-kernel/arch/ia64/kernel/crash.c
@@ -116,6 +116,10 @@ machine_crash_shutdown(struct pt_regs *p
 static void
 machine_kdump_on_init(void)
 {
+       if (!ia64_kimage) {
+               printk(KERN_NOTICE "Kdump not configured\n");
+               return;
+       }
        local_irq_disable();
        kexec_disable_iosapic();
        machine_kexec(ia64_kimage);
Index: current-kernel/arch/ia64/kernel/machine_kexec.c
=================================--- current-kernel.orig/arch/ia64/kernel/machine_kexec.c
+++ current-kernel/arch/ia64/kernel/machine_kexec.c
@@ -93,6 +93,7 @@ static void ia64_machine_kexec(struct un
        unsigned long vector;
        int ii;
 
+       BUG_ON(!image);
        if (image->type = KEXEC_TYPE_CRASH) {
                crash_save_this_cpu();
                current->thread.ksp = (__u64)info->sw - 16;
@@ -131,6 +132,7 @@ static void ia64_machine_kexec(struct un
 
 void machine_kexec(struct kimage *image)
 {
+       BUG_ON(!image);
        unw_init_running(ia64_machine_kexec, image);
        for(;;);
 }


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

* Re: [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
  2007-01-25 18:06 [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec() Bernhard Walle
@ 2007-01-27  6:28 ` Jes Sorensen
  2007-01-27 13:15 ` Bernhard Walle
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Jes Sorensen @ 2007-01-27  6:28 UTC (permalink / raw)
  To: linux-ia64

>>>>> "Bernhard" = Bernhard Walle <bwalle@suse.de> writes:

Bernhard> printk(KERN_NOTICE "Kdump not configured\n");

Hi Bernhard,

Wouldn't it make more sense to make that messages a bit more
descriptive? Ie. include something about what it tried to do when it
noticed it wasn't configured?

Cheers,
Jes

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

* Re: [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
  2007-01-25 18:06 [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec() Bernhard Walle
  2007-01-27  6:28 ` Jes Sorensen
@ 2007-01-27 13:15 ` Bernhard Walle
  2007-01-27 22:49 ` Jes Sorensen
  2007-01-28 12:47 ` Bernhard Walle
  3 siblings, 0 replies; 6+ messages in thread
From: Bernhard Walle @ 2007-01-27 13:15 UTC (permalink / raw)
  To: linux-ia64

Hello Jes,

* Jes Sorensen <jes@sgi.com> [2007-01-27 07:28]:
> >>>>> "Bernhard" = Bernhard Walle <bwalle@suse.de> writes:
> 
> Bernhard> printk(KERN_NOTICE "Kdump not configured\n");
> 
> Wouldn't it make more sense to make that messages a bit more
> descriptive? Ie. include something about what it tried to do when it
> noticed it wasn't configured?

Do you think 

    machine_kdump_on_init(): kdump not configured

would be better? That would make it easier to find the position of the
message in code. Or did you think of a more verbal description like

    tried to dump but that's not possible because kdump was
    not configured (ia64_kimage = NULL)

But I think we shouldn't write novels in the kernel log. ;)

But feel free to suggest another proposal and I'll update the patch. I
just want to see it included in mainline.


Regards,
Bernhard

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

* Re: [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
  2007-01-25 18:06 [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec() Bernhard Walle
  2007-01-27  6:28 ` Jes Sorensen
  2007-01-27 13:15 ` Bernhard Walle
@ 2007-01-27 22:49 ` Jes Sorensen
  2007-02-06 11:40   ` Bernhard Walle
  2007-01-28 12:47 ` Bernhard Walle
  3 siblings, 1 reply; 6+ messages in thread
From: Jes Sorensen @ 2007-01-27 22:49 UTC (permalink / raw)
  To: linux-ia64

Bernhard Walle wrote:
> Hello Jes,
> 
> * Jes Sorensen <jes@sgi.com> [2007-01-27 07:28]:
>>>>>>> "Bernhard" = Bernhard Walle <bwalle@suse.de> writes:
>> Bernhard> printk(KERN_NOTICE "Kdump not configured\n");
>>
>> Wouldn't it make more sense to make that messages a bit more
>> descriptive? Ie. include something about what it tried to do when it
>> noticed it wasn't configured?
> 
> Do you think 
> 
>     machine_kdump_on_init(): kdump not configured
> 
> would be better? That would make it easier to find the position of the
> message in code. Or did you think of a more verbal description like

That would do just fine I think, anything to avoid having to run find
and grep on the tree to figure out where it came from :)

Cheers,
Jes

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

* [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
  2007-01-25 18:06 [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec() Bernhard Walle
                   ` (2 preceding siblings ...)
  2007-01-27 22:49 ` Jes Sorensen
@ 2007-01-28 12:47 ` Bernhard Walle
  3 siblings, 0 replies; 6+ messages in thread
From: Bernhard Walle @ 2007-01-28 12:47 UTC (permalink / raw)
  To: linux-ia64

[After changing the message, 2nd try:]

This patch fixes a NULL-pointer dereference in ia64_machine_kexec().

The variable ia64_kimage is set in machine_kexec_prepare() which is
called from sys_kexec_load(). If kdump wasn't configured before,
ia64_kimage is NULL.  machine_kdump_on_init() passes ia64_kimage() to
machine_kexec() which assumes a valid value.

The patch also adds a few sanity checks for the image to simplify
debugging of similar problems in future.

Signed-off-by: Bernhard Walle <bwalle@suse.de>

---
 arch/ia64/kernel/crash.c         |    5 +++++
 arch/ia64/kernel/machine_kexec.c |    2 ++
 2 files changed, 7 insertions(+)

Index: b/arch/ia64/kernel/crash.c
=================================--- a/arch/ia64/kernel/crash.c
+++ b/arch/ia64/kernel/crash.c
@@ -116,6 +116,11 @@ machine_crash_shutdown(struct pt_regs *p
 static void
 machine_kdump_on_init(void)
 {
+	if (!ia64_kimage) {
+		printk(KERN_NOTICE "machine_kdump_on_init(): "
+				"kdump not configured\n");
+		return;
+	}
 	local_irq_disable();
 	kexec_disable_iosapic();
 	machine_kexec(ia64_kimage);
Index: b/arch/ia64/kernel/machine_kexec.c
=================================--- a/arch/ia64/kernel/machine_kexec.c
+++ b/arch/ia64/kernel/machine_kexec.c
@@ -93,6 +93,7 @@ static void ia64_machine_kexec(struct un
 	unsigned long vector;
 	int ii;
 
+	BUG_ON(!image);
 	if (image->type = KEXEC_TYPE_CRASH) {
 		crash_save_this_cpu();
 		current->thread.ksp = (__u64)info->sw - 16;
@@ -131,6 +132,7 @@ static void ia64_machine_kexec(struct un
 
 void machine_kexec(struct kimage *image)
 {
+	BUG_ON(!image);
 	unw_init_running(ia64_machine_kexec, image);
 	for(;;);
 }

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

* [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec()
  2007-01-27 22:49 ` Jes Sorensen
@ 2007-02-06 11:40   ` Bernhard Walle
  0 siblings, 0 replies; 6+ messages in thread
From: Bernhard Walle @ 2007-02-06 11:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-ia64, linux-kernel, fastboot

[I got no response after my corrected patch, so I try it again.
I request it to appear in -mm tree. Patch is against 2.6.20-rc6-mm3.]

This patch fixes a NULL-pointer dereference in ia64_machine_kexec().

The variable ia64_kimage is set in machine_kexec_prepare() which is
called from sys_kexec_load(). If kdump wasn't configured before,
ia64_kimage is NULL.  machine_kdump_on_init() passes ia64_kimage() to
machine_kexec() which assumes a valid value.

The patch also adds a few sanity checks for the image to simplify
debugging of similar problems in future.

Signed-off-by: Bernhard Walle <bwalle@suse.de>

---
 arch/ia64/kernel/crash.c         |    5 +++++
 arch/ia64/kernel/machine_kexec.c |    2 ++
 2 files changed, 7 insertions(+)

Index: b/arch/ia64/kernel/crash.c
=================================--- a/arch/ia64/kernel/crash.c
+++ b/arch/ia64/kernel/crash.c
@@ -116,6 +116,11 @@ machine_crash_shutdown(struct pt_regs *p
 static void
 machine_kdump_on_init(void)
 {
+	if (!ia64_kimage) {
+		printk(KERN_NOTICE "machine_kdump_on_init(): "
+				"kdump not configured\n");
+		return;
+	}
 	local_irq_disable();
 	kexec_disable_iosapic();
 	machine_kexec(ia64_kimage);
Index: b/arch/ia64/kernel/machine_kexec.c
=================================--- a/arch/ia64/kernel/machine_kexec.c
+++ b/arch/ia64/kernel/machine_kexec.c
@@ -93,6 +93,7 @@ static void ia64_machine_kexec(struct un
 	unsigned long vector;
 	int ii;
 
+	BUG_ON(!image);
 	if (image->type = KEXEC_TYPE_CRASH) {
 		crash_save_this_cpu();
 		current->thread.ksp = (__u64)info->sw - 16;
@@ -131,6 +132,7 @@ static void ia64_machine_kexec(struct un
 
 void machine_kexec(struct kimage *image)
 {
+	BUG_ON(!image);
 	unw_init_running(ia64_machine_kexec, image);
 	for(;;);
 }

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

end of thread, other threads:[~2007-02-06 11:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-25 18:06 [PATCH] Fix NULL-pointer dereference in ia64_machine_kexec() Bernhard Walle
2007-01-27  6:28 ` Jes Sorensen
2007-01-27 13:15 ` Bernhard Walle
2007-01-27 22:49 ` Jes Sorensen
2007-02-06 11:40   ` Bernhard Walle
2007-01-28 12:47 ` Bernhard Walle

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