Skip to contentSkip to conversation

Fix mmap_kmem (was: [question] What's the difference between /dev/kmem and /dev/mem)

PATCH Andi Kleen 3 participants 5 messages Aug 12, 2005 – Aug 13, 2005 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1123796188.17269.127.camel@localhost.localdomain.suse.lists.linux.kernel

A message that is not in the archive (sent off-list or not yet received): 1123809302.17269.139.camel@localhost.localdomain.suse.lists.linux.kernel

A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.58.0508120930150.3295@g5.osdl.org.suse.lists.linux.kernel

Andi Kleen

author
#3 lore raw
Quoted 3 lines · Linus Torvalds

I'm actually more inclined to try to deprecate /dev/kmem.. I don't think anybody has ever really used it except for some rootkits.

I don't think that's true.

Quoted 2 lines

So I'd be perfectly happy to fix this, but I'd be even happier if we made the whole kmem thing a config variable (maybe even default it to "off").

Acessing vmalloc in /dev/mem would be pretty awkward. Yes it doesn't also work in mmap of /dev/kmem, but at least in read/write. There are quite a lot of scripts that use it for kernel debugging like dumping variables. And for that you really want to access modules and vmalloc. And it's much easier to parse than /proc/kcore

In fact I have some patches queued to fix it for x86-64 again (people who used such scripts on i386 are complaining)

-Andi

#4 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Linus Torvalds

I'm actually more inclined to try to deprecate /dev/kmem.. I don't think anybody has ever really used it except for some rootkits.

I don't think that's true.

got any examples ?

Quoted 9 lines
Quoted 3 lines

So I'd be perfectly happy to fix this, but I'd be even happier if we made the whole kmem thing a config variable (maybe even default it to "off").

Acessing vmalloc in /dev/mem would be pretty awkward. Yes it doesn't also work in mmap of /dev/kmem, but at least in read/write. There are quite a lot of scripts that use it for kernel debugging like dumping variables. And for that you really want to access modules and vmalloc. And it's much easier to parse than /proc/kcore

but you can stick gdb on /proc/kcore...

author
#5 lore raw
Quoted 9 lines · Arjan van de Ven
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Linus Torvalds

I'm actually more inclined to try to deprecate /dev/kmem.. I don't think anybody has ever really used it except for some rootkits.

I don't think that's true.

got any examples ?

I wrote some hacks over the years, not sure it would be useful to post them because they all were very special purpose.

I know users are doing the same because they complain on x86-64 when it doesn't work.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

So I'd be perfectly happy to fix this, but I'd be even happier if we made the whole kmem thing a config variable (maybe even default it to "off").

Acessing vmalloc in /dev/mem would be pretty awkward. Yes it doesn't also work in mmap of /dev/kmem, but at least in read/write. There are quite a lot of scripts that use it for kernel debugging like dumping variables. And for that you really want to access modules and vmalloc. And it's much easier to parse than /proc/kcore

but you can stick gdb on /proc/kcore...

That's much more complicated. Instead of a simple read you would need to parse complex ASCII output. Also gdb normally doesn't work with a single System.map or /proc/kallsyms. I know it could be gotten to use that stuff, but that would be all very complicated. Much more complicated than read/write on /dev/kmem.

-Andi

#6 lore raw
In reply to Andi Kleen

Hi Andi,

Quoted 5 lines · Andi Kleen

Acessing vmalloc in /dev/mem would be pretty awkward. Yes it doesn't also work in mmap of /dev/kmem, but at least in read/write. There are quite a lot of scripts that use it for kernel debugging like dumping variables. And for that you really want to access modules and vmalloc. And it's much easier to parse than /proc/kcore

Perfect! So it should be under CONFIG_DEBUG_KERNEL and default to off.

So you can still debug and we raise the bar higher for rootkits, if they are the only other user.

Too simple?

Regards

Ingo Oeser

author
#7 lore raw
Quoted 6 lines

Perfect! So it should be under CONFIG_DEBUG_KERNEL and default to off.

So you can still debug and we raise the bar higher for rootkits, if they are the only other user.

Too simple?

If you wanted to recompile your kernel to debug you could as well add printks. But the whole point of kmem hacks is to avoid that slow cycle.

-Andi