copy_to_user,copy_from_user,get_user,put_user function Comparison
copy_to_user -Copy a block of data into user space.
copy_from_user -Copy a block of data from user space.
Get_user --Get a simple variable from user space.
put_user --Write a simple value into user space. the difference between Put_user and memcpy in Linux
First Linux kernel and the user app run in different modes. On ARM is kernel running in SVC mode (superlative), app running in user mode. When the user app executes a system call to invoke the kernel code, kernel completes the CPU's mode switch. SVC mode can access more registers, if the user app in kernel direct access to the address, there may be the following problems: The incoming address is wrong, then kernel can also access, may corrupt other kernel content, which can cause security problems, memcpy does not conduct an address check, the use of dedicated put_user will perform an address check to determine whether it is <0xc0000000, whether in the user app address space. At the same time on the arm platform, the last function called is __PUT_USER_1/2/4/8. This is a assembler function, using the data Access command for LDRBT, this arm assembly instruction uses user mode to access the memory, if this access is illegal, this will trigger a exception, in the kernel is added an exception function table, the exception is called __get_ User_bad
Copy_to_user,copy_from_user,get_user,put_user function Comparison