Why does copy_to_user fail after process forked?

33 Views Asked by At

I'm writing a kernel module that would write some data to user space buffer via copy_to_user. However, I found that copy_to_user always fails (returns non-zero) after the process forks. (copy_to_user works fine if I don't fork the process.) copy_to_user was called right after forked and I've used access_ok to check accessibility of the destination address.

I'm aware that after forking, child process will share meory with parent process due to copy-on-write mechanism. So I assume the reason that copy_to_user failed after fork might due to COW page fault.

My questions are,

  1. Is my assumption about COW mechanism causing copy_to_user failed true?
  2. If above is true, why didn't kernel handle page fault? Or What should I do to make copy_to_user work after process fork?
0

There are 0 best solutions below