When a user transfers data to kernel space, this data can be divided into several pages, and these pages can even be in changed memory. In these cases, you have to wait until the kernel changes on the page and gets access to the page on which the data is located. In the case of elementary data types (for example, int or pointers) it is also true that some architectures (especially x86 intel) do not force the user to align the data, so even an integer can be divided on the page border. You may have access to the first part of your integer, but wait until the second is replaced by the memory manager before everything is available.
You can save some callbacks by placing all user data in a structure whose pointer is passed to the kernel. You can copy_from_user this as a block and retain access (and be at risk of blocking several times)
So, and as a conclusion, use functions even for basic types , since there are a lot of them. Do not assume anything about where user data may be when working in kernel mode. You have access to it, but the virtual addresses of the kernel of user data have nothing to do with the virtual addresses visible in user mode.
source share