kernel hacking question

This is a discussion on kernel hacking question within the Linux Security forums, part of the System Security and Security Related category; Hi, im writing my first LKM and i've run into a problem...i wrote a replacement for sys_query_modules that ...


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-16-2004
Moe A
 
Posts: n/a
Default kernel hacking question

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);


}
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0