[lkml]   [2005]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectCannot read from /dev/kmem

Kernel 2.6.11 , I cannot seem to be able to read from /dev/kmem... The
following little proggie

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

struct {
unsigned short limit;
unsigned int base;
} __attribute__ ((packed)) idtr;

struct {
unsigned short off1;
unsigned short sel;
unsigned char none,flags;
unsigned short off2;
} __attribute__ ((packed)) idt;

int main()
int result, kmem = open ("/dev/kmem",O_RDONLY);

asm ("sidt %0" : "=m" (idtr));
printf("idtr base at 0x%X\n",(int)idtr.base);

if (kmem<0) return 1;

if (lseek(kmem, idtr.base + 8*0x80,SEEK_SET) != idtr.base +
8*0x80 )
perror("kmem lseek"); exit(1);

result = read(kmem, &idt , sizeof(idt) );

if( result != sizeof(idt) )
printf("result: %d, sizeof(idt)= %d errno=%d\n", result,
sizeof(idt), errno);


return 0;


utumno:/home/leszek/progs/module/hijack# ./test
idtr base at 0xC0423000
result: -1, sizeof(idt)= 8 errno=22


I remember this working on a 2.4.x kernel....

Leszek Koltunski
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-05-04 17:24    [W:0.033 / U:1.000 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site