Re: doubts for copy_from_user

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

 



Hi Vishal,

On Sun, Jul 3, 2011 at 5:09 AM, Vishal Thanki <vishalthanki@xxxxxxxxx> wrote:
> Hi,
>
> We use copy_from_user/copy_to_user functions to copy data transfer
> user data between user space and kernel space. As per my
> understanding, these functions are required because we cannot access
> userspace data directly within kernel space. But, the implementation
> of these functions actually access the user-space data right? Can
> someone explain me how this actually happens?

How it actually happens is architecture dependent. Whether kernel
space can access user space while in the context of the user-process
is also architecture dependent. I know with ARM, for example, it's
possible to do memcpy instead of copy_to_user, but using memcpy isn't
guaranteed to work on all architectures.

The other difference between memcpy and copy_to/from_user is that
memcpy will typically cause a segmentation fault if passed a bad
pointer, where copy_to/from_user won't.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[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