Problem with copy_from_user

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

 



Hi all,

I am trying to implement a protocol in linux kernel (2.6.14) for
experimental purposes and I am facing a weird problem.

I created a system call; in that code, the data read by copy_from user()
is correct.
rt is a pointer in kernel space and rt_u is a pointer in user space.

asmlinkage int sys_asimcast(struct routing_table *rt_u) {
	rt = rt_u;
	printk("Kernel has received pointer to routing table(%d);\n", (int)rt);
	if (rt != NULL) {
		struct routing_table local_rt;
		int n = copy_from_user(&local_rt, rt, sizeof(struct routing_table));
		printk("rt.session_list = %d; n = %d.\n", (int)local_rt.session_list, n);
	}
	return 2;
}

Now, I copied the same code in ip_rcv (/net/IPv4/ip_input.c) and the
data which is read is incorrect (the value of pointer rt remains the same);

struct routing_table local_rt;
if (rt != NULL) {
	n = get_rt(&local_rt, rt);
	printk("local_rt.session_list = %d; n = %d.\n",
(int)local_rt.session_list, n);
}

I am wondering if this problem has to do with the fact that
copy_from_user is user context only? If yes, should I change the context
and how?

Sorry if the question sounds stupid, but I've een struggling with that
issue for a while... :(
Best regards,

-- Laurent


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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