high_memory and module's address space.

Eleonora Autore (ely@ns1.avnet.co.uk)
Sat, 6 Nov 1999 19:14:34 +0000 (GMT)


Hi,

Imagine you are doing this:

1. Load a kernel module (any will do)

2. Generate kernel map (ksymoops -s map < /dev/null)

3. Note a few interesting data structures in the map and write
a trivial C program to dump them by reading off /dev/kmem. It
obviously works for addresses both in the statically linked and
modules (which are vmalloc()'d).

4. Now try to do the same in gdb (2.3.26-pre2 or later with ELF
/proc/kcore) and observe that it will fail for module addresses:

(gdb) p *(struct file_system_type *)0xc01db9cc
$5 = {name = 0xc01ba940 "devpts", fs_flags = 0, read_super = 0xc014f768
<devpts_read_super>,
next = 0xc4815b6c}
(gdb) p *(struct file_system_type *)0xc4815b6c
Cannot access memory at address 0xc4815b6c.

Why does it fail? Because we prevent it ourselves in
fs/proc/kcore.c:read_kcore():

size = ((size_t)high_memory - PAGE_OFFSET) + PAGE_SIZE;
if (buflen==0 || *fpos>=size)
return 0;

Now let us look at /dev/kmem read() method (read_kmem() in
drivers/char/mem.c) and see that it is using vread() in general
and does something else if (p<(unsigned long)high_memory).

So, what is your advice on how to proceed in allowing /proc/kcore
to access module's address space? use vread()? (tried - didn't work).
make read_kmem() not static? not nice (but it doesn't work either).

Any ideas?

Thanks in advance,
Tigran.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/