Help required!!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
	I am getting oops when i run a user land program to access data from simple 
kernel land driver.

	Can someone tell me where am i wrong???And how to correct it???

TIA
shan

P.S:i have enclose both userland appl. and kernal progrm. along with the oops 
message. 
<4>major number is 254
Inside test_open
Minor number is 0
Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01372a0
*pde = 00000000
Oops: 0002
CPU:    0
EIP:    0010:[<c01372a0>]    Tainted: P 
EFLAGS: 00010202
EIP is at fget [kernel] 0x20 
eax: c41d0000   ebx: c44ee000   ecx: 00000003   edx: 00000015
esi: fffffff7   edi: bffff9a4   ebp: 0000000d   esp: c44eff8c
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2880, stackpage=c44ef000)
Stack: c01365e9 c44effbc c60f0000 c768e260 c773f980 c44ee000 00000000 c7678000 
       c0302640 c44ee000 40016b4c bffff9a4 bffff938 c0106f3b 00000003 bffff920 
       0000000d 40016b4c bffff9a4 bffff938 00000003 0000002b 0000002b 00000003 
Call Trace: [<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: ff 42 14 89 d0 c3 8d 76 00 8d bc 27 00 00 00 00 8b 4c 24 04 
 <1>Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01361e6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01361e6>]    Tainted: P 
EFLAGS: 00010202
EIP is at filp_close [kernel] 0x6 
eax: c41d0000   ebx: 00000015   ecx: 00000000   edx: 00000015
esi: c384f7a0   edi: 00000001   ebp: 00000003   esp: c44efe38
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2880, stackpage=c44ef000)
Stack: 00000001 c384f7a0 c0119e5c 00000015 c384f7a0 00000000 c44ee000 0000000b 
       c44eff58 c011a461 c384f7a0 c022d63e c44eff58 c011439e c0230ec0 00000002 
       c0107497 00000000 c023166d c022c0f2 c022d63e 00000002 00000001 00000000 
Call Trace: [<c0119e5c>] put_files_struct [kernel] 0x4c 
[<c011a461>] do_exit [kernel] 0xd1 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c011439e>] bust_spinlocks [kernel] 0x3e 
[<c0230ec0>] .rodata.str1.1 [kernel] 0x53bb 
[<c0107497>] die [kernel] 0x47 
[<c023166d>] .rodata.str1.1 [kernel] 0x5b68 
[<c022c0f2>] .rodata.str1.1 [kernel] 0x5ed 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c01372a0>] fget [kernel] 0x20 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c01147f7>] do_page_fault [kernel] 0x377 
[<c0177266>] vt_console_print [kernel] 0x2a6 
[<c01179b6>] __call_console_drivers [kernel] 0x46 
[<c0117b2b>] call_console_drivers [kernel] 0xeb 
[<c0117cb0>] printk [kernel] 0x100 
[<c01476ec>] dput [kernel] 0x1c 
[<c80c71da>] test_read [number] 0x136 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c0107038>] error_code [kernel] 0x38 
[<c01372a0>] fget [kernel] 0x20 
[<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: 8b 43 14 85 c0 75 13 68 60 82 21 c0 e8 b9 19 fe ff 59 31 c0 
 <4>Inside test_open
Minor number is 0
Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01372a0
*pde = 00000000
Oops: 0002
CPU:    0
EIP:    0010:[<c01372a0>]    Tainted: P 
EFLAGS: 00010202
EIP is at fget [kernel] 0x20 
eax: c41d0800   ebx: c44ee000   ecx: 00000003   edx: 00000015
esi: fffffff7   edi: bffff3a4   ebp: 00000001   esp: c44eff8c
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2892, stackpage=c44ef000)
Stack: c01365e9 c44effbc c60f0000 c768e260 c773f980 c44ee000 00000000 c7678000 
       c0302640 c44ee000 40016b4c bffff3a4 bffff338 c0106f3b 00000003 bffff320 
       00000001 40016b4c bffff3a4 bffff338 00000003 0000002b 0000002b 00000003 
Call Trace: [<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: ff 42 14 89 d0 c3 8d 76 00 8d bc 27 00 00 00 00 8b 4c 24 04 
 <1>Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01361e6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01361e6>]    Tainted: P 
EFLAGS: 00010202
EIP is at filp_close [kernel] 0x6 
eax: c41d0800   ebx: 00000015   ecx: 00000000   edx: 00000015
esi: c384fc80   edi: 00000001   ebp: 00000003   esp: c44efe38
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2892, stackpage=c44ef000)
Stack: 00000001 c384fc80 c0119e5c 00000015 c384fc80 00000000 c44ee000 0000000b 
       c44eff58 c011a461 c384fc80 c022d63e c44eff58 c011439e c0230ec0 00000002 
       c0107497 00000000 c023166d c022c0f2 c022d63e 00000002 00000001 00000000 
Call Trace: [<c0119e5c>] put_files_struct [kernel] 0x4c 
[<c011a461>] do_exit [kernel] 0xd1 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c011439e>] bust_spinlocks [kernel] 0x3e 
[<c0230ec0>] .rodata.str1.1 [kernel] 0x53bb 
[<c0107497>] die [kernel] 0x47 
[<c023166d>] .rodata.str1.1 [kernel] 0x5b68 
[<c022c0f2>] .rodata.str1.1 [kernel] 0x5ed 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c01372a0>] fget [kernel] 0x20 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c01147f7>] do_page_fault [kernel] 0x377 
[<c0177266>] vt_console_print [kernel] 0x2a6 
[<c01179b6>] __call_console_drivers [kernel] 0x46 
[<c0117b2b>] call_console_drivers [kernel] 0xeb 
[<c0117cb0>] printk [kernel] 0x100 
[<c01476ec>] dput [kernel] 0x1c 
[<c80c71da>] test_read [number] 0x136 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c0107038>] error_code [kernel] 0x38 
[<c01372a0>] fget [kernel] 0x20 
[<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: 8b 43 14 85 c0 75 13 68 60 82 21 c0 e8 b9 19 fe ff 59 31 c0 
 <1>Module dying<4>major number is 254
Inside test_open
Minor number is 0
Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01372a0
*pde = 00000000
Oops: 0002
CPU:    0
EIP:    0010:[<c01372a0>]    Tainted: P 
EFLAGS: 00010202
EIP is at fget [kernel] 0x20 
eax: c41d0c00   ebx: c44ee000   ecx: 00000003   edx: 00000015
esi: fffffff7   edi: bffff1a4   ebp: 00000001   esp: c44eff8c
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2896, stackpage=c44ef000)
Stack: c01365e9 c44effbc c60f0000 c768e260 c773f980 c44ee000 00000000 c7678000 
       c0302640 c44ee000 40016b4c bffff1a4 bffff138 c0106f3b 00000003 bffff120 
       00000001 40016b4c bffff1a4 bffff138 00000003 0000002b 0000002b 00000003 
Call Trace: [<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: ff 42 14 89 d0 c3 8d 76 00 8d bc 27 00 00 00 00 8b 4c 24 04 
 <1>Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01361e6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01361e6>]    Tainted: P 
EFLAGS: 00010202
EIP is at filp_close [kernel] 0x6 
eax: c41d0c00   ebx: 00000015   ecx: 00000000   edx: 00000015
esi: c384fe20   edi: 00000001   ebp: 00000003   esp: c44efe38
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2896, stackpage=c44ef000)
Stack: 00000001 c384fe20 c0119e5c 00000015 c384fe20 00000000 c44ee000 0000000b 
       c44eff58 c011a461 c384fe20 00000004 00000000 c022d63e c44eff58 c44eff58 
       c0230ec0 00000018 c0230018 ffffff00 c01074a3 00000010 00000292 00000000 
Call Trace: [<c0119e5c>] put_files_struct [kernel] 0x4c 
[<c011a461>] do_exit [kernel] 0xd1 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c0230ec0>] .rodata.str1.1 [kernel] 0x53bb 
[<c0230018>] .rodata.str1.1 [kernel] 0x4513 
[<c01074a3>] die [kernel] 0x53 
[<c01372a0>] fget [kernel] 0x20 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c01147f7>] do_page_fault [kernel] 0x377 
[<c0177266>] vt_console_print [kernel] 0x2a6 
[<c01179b6>] __call_console_drivers [kernel] 0x46 
[<c0117b2b>] call_console_drivers [kernel] 0xeb 
[<c0117cb0>] printk [kernel] 0x100 
[<c01476ec>] dput [kernel] 0x1c 
[<c80c71da>] test_read [number] 0x136 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c0107038>] error_code [kernel] 0x38 
[<c01372a0>] fget [kernel] 0x20 
[<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: 8b 43 14 85 c0 75 13 68 60 82 21 c0 e8 b9 19 fe ff 59 31 c0 
 <4>Inside test_open
Minor number is 0
Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01372a0
*pde = 00000000
Oops: 0002
CPU:    0
EIP:    0010:[<c01372a0>]    Tainted: P 
EFLAGS: 00010202
EIP is at fget [kernel] 0x20 
eax: c462d400   ebx: c44ee000   ecx: 00000003   edx: 00000015
esi: fffffff7   edi: bfffec24   ebp: 00000001   esp: c44eff8c
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2907, stackpage=c44ef000)
Stack: c01365e9 c44effbc c60f0000 c768e260 c773f980 c44ee000 00000000 c7678000 
       c0302640 c44ee000 40016b4c bfffec24 bfffebb8 c0106f3b 00000003 bfffebb4 
       00000001 40016b4c bfffec24 bfffebb8 00000003 0000002b 0000002b 00000003 
Call Trace: [<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: ff 42 14 89 d0 c3 8d 76 00 8d bc 27 00 00 00 00 8b 4c 24 04 
 <1>Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01361e6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01361e6>]    Tainted: P 
EFLAGS: 00010202
EIP is at filp_close [kernel] 0x6 
eax: c462d400   ebx: 00000015   ecx: 00000000   edx: 00000015
esi: c384f2c0   edi: 00000001   ebp: 00000003   esp: c44efe38
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2907, stackpage=c44ef000)
Stack: 00000001 c384f2c0 c0119e5c 00000015 c384f2c0 00000000 c44ee000 0000000b 
       c44eff58 c011a461 c384f2c0 c022d63e c44eff58 c011439e c0230ec0 00000002 
       c0107497 00000000 c023166d c022c0f2 c022d63e 00000002 00000001 00000000 
Call Trace: [<c0119e5c>] put_files_struct [kernel] 0x4c 
[<c011a461>] do_exit [kernel] 0xd1 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c011439e>] bust_spinlocks [kernel] 0x3e 
[<c0230ec0>] .rodata.str1.1 [kernel] 0x53bb 
[<c0107497>] die [kernel] 0x47 
[<c023166d>] .rodata.str1.1 [kernel] 0x5b68 
[<c022c0f2>] .rodata.str1.1 [kernel] 0x5ed 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c01372a0>] fget [kernel] 0x20 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c01147f7>] do_page_fault [kernel] 0x377 
[<c0177266>] vt_console_print [kernel] 0x2a6 
[<c01179b6>] __call_console_drivers [kernel] 0x46 
[<c0117b2b>] call_console_drivers [kernel] 0xeb 
[<c0117cb0>] printk [kernel] 0x100 
[<c01476ec>] dput [kernel] 0x1c 
[<c80c71da>] test_read [number] 0x136 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c0107038>] error_code [kernel] 0x38 
[<c01372a0>] fget [kernel] 0x20 
[<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: 8b 43 14 85 c0 75 13 68 60 82 21 c0 e8 b9 19 fe ff 59 31 c0 
 <4>Inside test_open
Minor number is 0
Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01372a0
*pde = 00000000
Oops: 0002
CPU:    0
EIP:    0010:[<c01372a0>]    Tainted: P 
EFLAGS: 00010202
EIP is at fget [kernel] 0x20 
eax: c462d000   ebx: c44ee000   ecx: 00000003   edx: 00000015
esi: fffffff7   edi: bffff224   ebp: 00000001   esp: c44eff8c
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2959, stackpage=c44ef000)
Stack: c01365e9 c44effbc c60f0000 c768e260 c773f980 c44ee000 00000000 c7678000 
       c0302640 c44ee000 40016b4c bffff224 bffff1b8 c0106f3b 00000003 bffff1b4 
       00000001 40016b4c bffff224 bffff1b8 00000003 0000002b 0000002b 00000003 
Call Trace: [<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: ff 42 14 89 d0 c3 8d 76 00 8d bc 27 00 00 00 00 8b 4c 24 04 
 <1>Unable to handle kernel NULL pointer dereference at virtual address 00000029
 printing eip:
c01361e6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01361e6>]    Tainted: P 
EFLAGS: 00010202
EIP is at filp_close [kernel] 0x6 
eax: c462d000   ebx: 00000015   ecx: 00000000   edx: 00000015
esi: c384f600   edi: 00000001   ebp: 00000003   esp: c44efe38
ds: 0018   es: 0018   ss: 0018
Process a.out (pid: 2959, stackpage=c44ef000)
Stack: 00000001 c384f600 c0119e5c 00000015 c384f600 00000000 c44ee000 0000000b 
       c44eff58 c011a461 c384f600 c022d63e c44eff58 c011439e c0230ec0 00000002 
       c0107497 00000000 c023166d c022c0f2 c022d63e 00000002 00000001 00000000 
Call Trace: [<c0119e5c>] put_files_struct [kernel] 0x4c 
[<c011a461>] do_exit [kernel] 0xd1 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c011439e>] bust_spinlocks [kernel] 0x3e 
[<c0230ec0>] .rodata.str1.1 [kernel] 0x53bb 
[<c0107497>] die [kernel] 0x47 
[<c023166d>] .rodata.str1.1 [kernel] 0x5b68 
[<c022c0f2>] .rodata.str1.1 [kernel] 0x5ed 
[<c022d63e>] .rodata.str1.1 [kernel] 0x1b39 
[<c01372a0>] fget [kernel] 0x20 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c01147f7>] do_page_fault [kernel] 0x377 
[<c0177266>] vt_console_print [kernel] 0x2a6 
[<c01179b6>] __call_console_drivers [kernel] 0x46 
[<c0117b2b>] call_console_drivers [kernel] 0xeb 
[<c0117cb0>] printk [kernel] 0x100 
[<c01476ec>] dput [kernel] 0x1c 
[<c80c71da>] test_read [number] 0x136 
[<c0114480>] do_page_fault [kernel] 0x0 
[<c0107038>] error_code [kernel] 0x38 
[<c01372a0>] fget [kernel] 0x20 
[<c01365e9>] sys_read [kernel] 0x19 
[<c0106f3b>] system_call [kernel] 0x33 


Code: 8b 43 14 85 c0 75 13 68 60 82 21 c0 e8 b9 19 fe ff 59 31 c0 
 
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>

#define BUFFSIZE 14

int main()
{
	char buf[BUFFSIZE];
	int recv;
	int fd=open("/dev/Test",O_RDONLY);

	if(fd < 0){
		perror("open");
		return -1;
	}

	recv=read(fd,buf,BUFFSIZE);
	if(recv < 0){
		perror("recv");
		return -1;
	}

	printf("%s\n",buf);
	printf("Byte recvd is %d\n",recv);

	close(fd);
	printf("Ending user prgm...\n");
	return 0;	
}
#define MODULE

#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/fs.h>
#include<asm/uaccess.h>

int test_major=0,major;
char *data="copy_to_user";


/*MODULE_PARM(val,"i");*/

/*typedef struct test_device {
	void **data;
	unsigned long size;
	struct semaphore sem;
}test_device;*/


static int test_open(struct inode *inode,struct file *filp)
{
	/*test_device *dev;*/
	int minor=MINOR(inode->i_rdev);

	printk(KERN_WARNING"Inside test_open\n");
	printk(KERN_WARNING"Minor number is %d\n",minor);
/*	MOD_INC_USE_COUNT;*/
}


static int test_release(struct inode *inode,struct file *filp)
{
	printk(KERN_WARNING"Inside test_release\n");
	return 0;
}


ssize_t test_read(struct file *filp,char *buf,size_t count,loff_t *fpos)
{
	/*test_device *dev=filp->private_data;*/
	/*test_device *devptr;
	devptr->data=data;*/
	printk(KERN_WARNING"Inside test_read before count init\n");
	count=0;

	count=copy_to_user(buf,data,13);

	if(count < 0){
		printk(KERN_WARNING"data could not be copied\n");
	}
	else
		printk(KERN_WARNING"data copied\n");
}

struct file_operations test_fops={
	llseek:	NULL,
	read:	test_read,
	write:	NULL,
	readdir:	NULL,
	poll:	NULL,
	ioctl:	NULL,
	mmap:	NULL,
	open:	test_open,
	flush:	NULL,
	release:	test_release,
	fsync:	NULL,
	fasync:	NULL,
	lock:	NULL,
	readv:	NULL,
	writev:	NULL,
	owner:	THIS_MODULE
};


int init_module()
{
	/*int count;*/
	major=register_chrdev(test_major,"Test",&test_fops);
	if(major < 0)
	{
		printk(KERN_WARNING"cant get major %d\n",test_major);
		return -1;
	}
	else
		printk(KERN_WARNING"major number is %d\n",major);
	return 0;
}


void cleanup_module()
{
	printk("<1>Module dying");
/*	MOD_DEC_USE_COUNT;*/
	unregister_chrdev(major,"Test");
}

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux