Hello friends Friends in the below mentioned program i am intercepting makedir system call so that user would not be able to make any directories . But i am getting " unresolved sysmbol sys_call_table " error while inserting the module .Plz help me 2 resolve it . Thanks a lot . My kernel version is 2.4.18.14 . gcc -DMODULE -D__KERNEL__ -I/usr/src/linux-2.4.18-14/include -Wall -O2 -c nodir.c -o nodir.o
/* program nodir.c */ #include <linux/version.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/smp_lock.h> #include <linux/sched.h> #include <linux/unistd.h> #include <linux/string.h> #include <linux/file.h> #include <asm/uaccess.h> #include <linux/proc_fs.h> #include <asm/errno.h> #include <asm/io.h> #include <sys/syscall.h>
extern void* sys_call_table[]; /*sys_call_table is exported, so we can access it*/
int (*orig_mkdir)(const char *path); /*the original systemcall*/
int hacked_mkdir(const char *path) { return 0; /*everything is ok, but he new systemcall does nothing*/ }
int init_module(void) /*module setup*/ { orig_mkdir=sys_call_table[__NR_mkdir]; sys_call_table[__NR_mkdir]=hacked_mkdir; return 0; }
void cleanup_module(void) /*module shutdown*/ { sys_call_table[__NR_mkdir]=orig_mkdir; /*set mkdir syscall to the origal one*/ }
MODULE_LICENSE("GPL");
===== shallinvites@rediffmail.com We all have ability. The difference is how we use it.
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
i tried ur code on kernel 2.4.18-14: gave me same error kernel 2.4.2-2: it worked when i do $grep -r 'sys_call_table' /usr/src/linux i see in kernel 2.4.2-2 /usr/src/linux/kernel/ksyms.c : EXPORT_SYMBOL( sys_call_table) in kernel 2.4.18-14 i dont see that
thats the reason y u r getting a
'unresolved symbol error' check out what is to be done for that...
-troy
--- Linux Handsome linuxhandsome@yahoo.com wrote:
Hello friends Friends in the below mentioned program i am intercepting makedir system call so that user would not be able to make any directories . But i am getting " unresolved sysmbol sys_call_table " error while inserting the module .Plz help me 2 resolve it . Thanks a lot . My kernel version is 2.4.18.14 . gcc -DMODULE -D__KERNEL__ -I/usr/src/linux-2.4.18-14/include -Wall -O2 -c nodir.c -o nodir.o
/* program nodir.c */ #include <linux/version.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/smp_lock.h> #include <linux/sched.h> #include <linux/unistd.h> #include <linux/string.h> #include <linux/file.h> #include <asm/uaccess.h> #include <linux/proc_fs.h> #include <asm/errno.h> #include <asm/io.h> #include <sys/syscall.h>
extern void* sys_call_table[]; /*sys_call_table is exported, so we can access it*/
int (*orig_mkdir)(const char *path); /*the original systemcall*/
int hacked_mkdir(const char *path) { return 0; /*everything is ok, but he new systemcall does nothing*/ }
int init_module(void) /*module setup*/ { orig_mkdir=sys_call_table[__NR_mkdir]; sys_call_table[__NR_mkdir]=hacked_mkdir; return 0; }
void cleanup_module(void) /*module shutdown*/ { sys_call_table[__NR_mkdir]=orig_mkdir; /*set mkdir syscall to the origal one*/ }
MODULE_LICENSE("GPL");
===== shallinvites@rediffmail.com We all have ability. The difference is how we use it.
Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com