2006-05-11 07:26:49

by Sharyathi Nagesh

[permalink] [raw]
Subject: Re: Bug while executing : cat /proc/iomem on 2.6.17-rc1/rc2

I was able to replicate the Bug, even when all the drivers are built into the kernel.
It looks like while traversing through p->parent field of resource structure is leading to NULL pointer.
Would it be appropriate to make the following code change.
But I found cat /proc/iomem hangs after line kernel data..

--- kernel/resource.c.old 2006-05-11 05:29:33.000000000 -0700
+++ kernel/resource.c 2006-05-11 05:29:58.000000000 -0700
@@ -81,7 +81,7 @@ static int r_show(struct seq_file *m, vo
int depth;

for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent){
- if (p->parent == root)
+ if (p->parent == root || p->parent == NULL)
break;
}
seq_printf(m, "%*s%0*lx-%0*lx : %s\n",
Regards
Sharyathi Nagesh

On Tue, 2006-04-25 at 12:48 +0200, Arjan van de Ven wrote:
> On Tue, 2006-04-25 at 16:13 +0530, Sachin Sant wrote:
> > I found this following problem while executing cat/proc/iomem. The
> > command causes following BUG.
> >
> > x236:/linux-2.6.17-rc1/fs # cat /proc/iomem
> > Segmentation fault
>
>
> this tends to be a driver bug; could you compile all the drivers you
> need as module, and then try to not load them as much as possible. See
> if it still crashes, if not, load the rest one at a time until it
> crashes, and then you've found the culprit :)
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>


2006-05-11 07:32:12

by Russell King

[permalink] [raw]
Subject: Re: Bug while executing : cat /proc/iomem on 2.6.17-rc1/rc2

On Thu, May 11, 2006 at 12:57:48PM +0530, Sharyathi Nagesh wrote:
> I was able to replicate the Bug, even when all the drivers are built into the kernel.
> It looks like while traversing through p->parent field of resource structure is leading to NULL pointer.
> Would it be appropriate to make the following code change.
> But I found cat /proc/iomem hangs after line kernel data..
>
> --- kernel/resource.c.old 2006-05-11 05:29:33.000000000 -0700
> +++ kernel/resource.c 2006-05-11 05:29:58.000000000 -0700
> @@ -81,7 +81,7 @@ static int r_show(struct seq_file *m, vo
> int depth;
>
> for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent){
> - if (p->parent == root)
> + if (p->parent == root || p->parent == NULL)
> break;
> }
> seq_printf(m, "%*s%0*lx-%0*lx : %s\n",

Only the root should have a NULL parent, so this is just covering up some
other problem - you have a resource which somehow has illegally ended up
with a NULL parent pointer while it's been registered.

Maybe try adding:

if (p->parent == NULL) {
printk("resource with null parent: %lx-%lx: %s\n",
p->start, p->end, p->name);
break;
}

just before the test in that loop, and then finding out why that resource
is becoming invalid.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2006-05-11 08:35:43

by Sachin Sant

[permalink] [raw]
Subject: Re: Bug while executing : cat /proc/iomem on 2.6.17-rc1/rc2

Russell King wrote:

>Only the root should have a NULL parent, so this is just covering up some
>other problem - you have a resource which somehow has illegally ended up
>with a NULL parent pointer while it's been registered.
>
>Maybe try adding:
>
> if (p->parent == NULL) {
> printk("resource with null parent: %lx-%lx: %s\n",
> p->start, p->end, p->name);
> break;
> }
>
>just before the test in that loop, and then finding out why that resource
>is becoming invalid.
>
>
>
I get this output in dmesg with the above code.

resource with null parent: 0-57ffffff: System RAM
resource with null parent: 0-57ffffff: System RAM

x236:/home/sharyathi/linux-2.6.17-rc1/kernel # cat /proc/iomem
00000000-0009dbff : System RAM
0009dc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000cafff : Video ROM
000cb000-000cc5ff : Adapter ROM
000f0000-000fffff : System ROM
00100000-c7fcb5ff : System RAM
00100000-004ff436 : Kernel code
004ff437-0068881f : Kernel data
x236:/home/sharyathi/linux-2.6.17-rc1/kernel #



2006-05-13 10:31:07

by Maneesh Soni

[permalink] [raw]
Subject: Re: Bug while executing : cat /proc/iomem on 2.6.17-rc1/rc2

On Thu, May 11, 2006 at 02:08:12PM +0530, Sachin Sant wrote:
> Russell King wrote:
>
> >Only the root should have a NULL parent, so this is just covering up some
> >other problem - you have a resource which somehow has illegally ended up
> >with a NULL parent pointer while it's been registered.
> >
> >Maybe try adding:
> >
> > if (p->parent == NULL) {
> > printk("resource with null parent: %lx-%lx: %s\n",
> > p->start, p->end, p->name);
> > break;
> > }
> >
> >just before the test in that loop, and then finding out why that resource
> >is becoming invalid.
> >
> >
> >
> I get this output in dmesg with the above code.
>
> resource with null parent: 0-57ffffff: System RAM
> resource with null parent: 0-57ffffff: System RAM
>
> x236:/home/sharyathi/linux-2.6.17-rc1/kernel # cat /proc/iomem
> 00000000-0009dbff : System RAM
> 0009dc00-0009ffff : reserved
> 000a0000-000bffff : Video RAM area
> 000c0000-000cafff : Video ROM
> 000cb000-000cc5ff : Adapter ROM
> 000f0000-000fffff : System ROM
> 00100000-c7fcb5ff : System RAM
> 00100000-004ff436 : Kernel code
> 004ff437-0068881f : Kernel data
> x236:/home/sharyathi/linux-2.6.17-rc1/kernel #
>

Backing out

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=10dbe196a8da6b3196881269c6639c0ec11c36cb

solves this problem for me. This patch adds memory more than 4G to /proc/iomem
but without 64-bit fields for struct resource it ends up in confusing
iomem_resource list. I think this patch needs the core 64-bit struct resource
related changes also.


Thanks
Maneesh

2006-05-13 14:56:49

by Linus Torvalds

[permalink] [raw]
Subject: Re: Bug while executing : cat /proc/iomem on 2.6.17-rc1/rc2



On Sat, 13 May 2006, Maneesh Soni wrote:
>
> Backing out
>
> http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=10dbe196a8da6b3196881269c6639c0ec11c36cb
>
> solves this problem for me. This patch adds memory more than 4G to /proc/iomem
> but without 64-bit fields for struct resource it ends up in confusing
> iomem_resource list. I think this patch needs the core 64-bit struct resource
> related changes also.

Yeah, let's revert that for now. I don't think the people involved
realized how it was dependent on the 64-bit struct resource changes.

Thanks,

Linus