I read the source code of copy_from/to_user
functions.
It seems that they always return 0
.
static inline int copy_from_user(void *to, const void __user volatile *from,
unsigned long n)
{
__chk_user_ptr(from, n);
volatile_memcpy(to, from, n);
return 0;
}
However, there is some code like below that checks the returned value of copy_from/to_user
.
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
return -EFAULT;
Then I have three questions.
- Where the code of
copy_from/to_user
which returns non-zero is defined? - What causes the
copy_from/to_user
to return a non-zero value? - What value is returned?