Copy_to_user,copy_from_user,get_user,put_user function Comparison

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.