Why is copy_to / from_user required?

According to Linux design on x86 and ppc, the 4g virtual address space is divided by 3: 1. User virtual address up to 3g.

Now, if the user application executes ioctl, passing the pointer to the buffer, the kernel module can directly execute memcpy, I tried and worked. => Why do we need the user copy_to / copy_from.

Note. If the page is exchanged, then the error handler in the kernel file will return, and it is invisible to the kernel module.

need yr ideas ... comments

+5
source share
2 answers

There are several good reasons why copy_to_user/ copy_from_userare the correct functions:

  • memcpy() , . , x86 HIGHMEM config .

  • access_ok(), , , , . memcpy(), ioctl() , , .

  • . memcpy(), . "fixup" , ( EFAULT ).

+9

, .

. copy_to_user, ​​ . .

/ , / DMA. , DMA . , , - ( mmaps).

0

All Articles