Привет! может мне ктото сказать каким образом или с помощью какой функции
можно связать структуру "struct file" с каким либо файлом, например "/etc/passwd",
я попробывал ниже приведенный код, но нечего не вышло:(
# cat m.c
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
int fd, errno ;
struct file *tty_file ;
static inline _syscall2(int, open, const char *, pathname, int, flags) ;
int
init_module()
{
fd = open("/etc/passwd", 00) ;
tty_file = fget(fd) ;
printk("%d\n", tty_file->f_uid) ;
return 0 ;
}
void cleanup_module()
{
}
EOF
Компилю
# gcc -c m.c
загружаю
# insmod -f m.o
После чего модуль уходит в "segfault" с ощибкой "Упс" и в "/var/log/messages" пишеться
Unable to handle kernel NULL pointer dereference at virtual address 0000004c
printing eip:
d08600bd
pgd entry c8834000: 0000000000000000
pmd entry c8834000: 0000000000000000
... pmd not present!
Oops: 0000
CPU: 0
EIP: 0010:[<d08600bd>]
EFLAGS: 00010282
eax: 00000000 ebx: d0860000 ecx: ffffffff
edx: 00000000
esi: d0860080 edi: 00000000 ebp: c8833f14
esp: c8833f04
ds: 0018 es: 0018 ss: 0018
Process insmod (pid: 1007, stackpage=c8833000)Mar 30 09:36:33 localhost kernel: Stack: c0229900 00000216 000042f9 c012972e 00000250 c0114aa8 c8832000 0804b500
0807dc88 bfffca98 00000000 00000008 00000000 c8833f60 00000060 00000000
c95f0000 00000154 00000060 00000001 c95f2000 ffffffea ca6e24e0 00000060
Call Trace: [<c012972e>] [<c0114aa8>] [<d085e000>] [<d0860060>] [<c0106f23>]
Code: ff 70 4c 68 4f 01 86 d0 e8 a2 3c 8b ef 83 c4 10 b8 00 00 00
Пример кода взят из Прака (там где описывался кейлогер под Линукс), только там код чуть другой
(но у меня с ним такиеже траблы)
"F1" please:)