Kernel Hacking Question
From: Moe A (htgk_at_mail.com)
Date: 06/16/04
- Next message: Oded: "Read only Disk and Ram-Drive"
- Previous message: David W. Fenton: "Re: Open source alternative for MsAccess?"
- Next in thread: mjt: "Re: Kernel Hacking Question"
- Reply: mjt: "Re: Kernel Hacking Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Jun 2004 02:30:51 -0700
Hi,
im writing my first LKM and i've run into a problem...i wrote a
replacement for sys_query_modules that prints out the names of the
loaded modules when its called with "QM_MODULES" as the which argument
(it does this by calling the original query_modules and then iterating
through the list it fills). but each time i try to dereference the
pointer to the list of adjacent strings, the system dies with a nasty
"kernel NULL pointer dereference" (even if i check that its not null
first)
so i thought maybe the list cant be accessed or needs to be copied
from user space, so i wrote another version that you can see
below..after i insert the module and run lsmod, i get "access is not
ok" printed a bunch of times (you'll have to look at the code to
understand)...so my question is whether or not its possible to
read/write the buffer argument after its filled by sys_query_modules
(uname -a is "Linux jukebox 2.4.21-99-smp4G #1 SMP Wed Sep 24 14:13:20
UTC 2003 i686 i686 i386 GNU/Linux" and lsmod is lsmod.old)
int new_query_module(const char *name, int which, char *buf, size_t
bufsize, size_t *ret)
{
char *ptr;
int retval;
retval= original_query_module(name, which, buf, bufsize, ret);
if(retval == -1)
return(-errno);
if(which != QM_MODULES)
return(retval);
if(buf != NULL)
if(access_ok(%VERIFY_READ, buf, bufsize) == 0) {
printk("access is ok\n");
if(copy_from_user(ptr, buf, bufsize) == 0)
printk("copied it all\n");
else
printk("couldnt copy it all\n");
} else
printk("access is not ok\n");
else
printk("buf is null\n");
return(retval);
}
- Next message: Oded: "Read only Disk and Ram-Drive"
- Previous message: David W. Fenton: "Re: Open source alternative for MsAccess?"
- Next in thread: mjt: "Re: Kernel Hacking Question"
- Reply: mjt: "Re: Kernel Hacking Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|