Why does the kernel use the copy_to_user function?
Couldn’t it just directly operate on data in the user space?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
kernel and user-space applications have different address spaces, so copying to user space require an address space change. Each process has its own (user) address space.
Also, kernel should never crash when copying to user space, so the
copy_to_userfunction probably checks that the destination address is valid (perhaps that address should be paged-in, e.g. from swap space).Read more about linux kernel, syscalls, processes, address space …