3

I'm reading LDD3. In chapter 8, I could not understand this paragraph:

An example of a function in the kernel that uses vmalloc is the create_module system call, which uses vmalloc to get space for the module being created. Code and data of the module are later copied to the allocated space using copy_from_user. In this way, the module appears to be loaded into contiguous memory.

Why is copy_from_user used? Aren't we in kernel space only?

Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75
user1047069
  • 935
  • 2
  • 13
  • 25

1 Answers1

3

Recall that kernel modules are loaded by the insmod (or modprobe) command, which runs in user space. These commands load the kernel module from disk into memory, then pass it to the kernel, which must use copy_from_user() to copy that to kernel memory.