linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area
@ 2010-11-09  4:20 Steven Rostedt
  2010-11-11 17:09 ` Jesse Barnes
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2010-11-09  4:20 UTC (permalink / raw)
  To: LKML; +Cc: Andrew Morton, Jesse Barnes, Chandru Siddalingappa

While testing various randconfigs with ktest.pl, I hit the following panic:

BUG: unable to handle kernel paging request at f7e54b03
IP: [<c0d63409>] ibmphp_access_ebda+0x101/0x19bb

Adding printks, I found that the loop that reads the ebda blocks
can move out of the mapped section.

ibmphp_access_ebda: start=f7e44c00 size=5120 end=f7e46000
ibmphp_access_ebda: io_mem=f7e44d80 offset=384
ibmphp_access_ebda: io_mem=f7e54b03 offset=65283

The start of the iomap was at f7e44c00 and had a size of 5120,
making the end f7e46000. We start with an offset of 0x180 or
384, giving the first read at 0xf7e44d80. Reading that location
yields 65283, which is much bigger than the 5120 that was allocated
and makes the next read at f7e54b03 which is outside the mapped area.

Perhaps this is a bug in the driver, or buggy hardware, but this patch
is more about not crashing my box on start up and just giving a warning
if it detects this error.

This patch at least lets my box boot with just a warning.

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Chandru Siddalingappa <chandru@linux.vnet.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

---
 drivers/pci/hotplug/ibmphp_ebda.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-test.git/drivers/pci/hotplug/ibmphp_ebda.c
===================================================================
--- linux-test.git.orig/drivers/pci/hotplug/ibmphp_ebda.c	2010-11-08 23:02:04.514138224 -0500
+++ linux-test.git/drivers/pci/hotplug/ibmphp_ebda.c	2010-11-08 23:02:38.021316682 -0500
@@ -276,6 +276,12 @@ int __init ibmphp_access_ebda (void)
 
 	for (;;) {
 		offset = next_offset;
+
+		/* Make sure what we read is still in the mapped section */
+		if (WARN(offset > (ebda_sz * 1024 - 4),
+			 "ibmphp_ebda: next read is beyond ebda_sz\n"))
+			break;
+
 		next_offset = readw (io_mem + offset);	/* offset of next blk */
 
 		offset += 2;



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

* Re: [PATCH] PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area
  2010-11-09  4:20 [PATCH] PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area Steven Rostedt
@ 2010-11-11 17:09 ` Jesse Barnes
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2010-11-11 17:09 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Andrew Morton, Chandru Siddalingappa

On Mon, 08 Nov 2010 23:20:27 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> While testing various randconfigs with ktest.pl, I hit the following panic:
> 
> BUG: unable to handle kernel paging request at f7e54b03
> IP: [<c0d63409>] ibmphp_access_ebda+0x101/0x19bb
> 
> Adding printks, I found that the loop that reads the ebda blocks
> can move out of the mapped section.
> 
> ibmphp_access_ebda: start=f7e44c00 size=5120 end=f7e46000
> ibmphp_access_ebda: io_mem=f7e44d80 offset=384
> ibmphp_access_ebda: io_mem=f7e54b03 offset=65283
> 
> The start of the iomap was at f7e44c00 and had a size of 5120,
> making the end f7e46000. We start with an offset of 0x180 or
> 384, giving the first read at 0xf7e44d80. Reading that location
> yields 65283, which is much bigger than the 5120 that was allocated
> and makes the next read at f7e54b03 which is outside the mapped area.
> 
> Perhaps this is a bug in the driver, or buggy hardware, but this patch
> is more about not crashing my box on start up and just giving a warning
> if it detects this error.
> 
> This patch at least lets my box boot with just a warning.
> 
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: Chandru Siddalingappa <chandru@linux.vnet.ibm.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> ---
>  drivers/pci/hotplug/ibmphp_ebda.c |    6 ++++++
>  1 file changed, 6 insertions(+)

Applied to my for-linus branch, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

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

end of thread, other threads:[~2010-11-11 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-09  4:20 [PATCH] PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area Steven Rostedt
2010-11-11 17:09 ` Jesse Barnes

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