I'm trying to write a test in which copy_to_user() fails (only copies some of the data, or none at all, without using NULL pointers), but am unsuccessful.
The test, in user mode has the lines:
type to[1];
foo(to);
foo is a wrapper function which calls a system-call that has the lines:
type from[2] = {something1, something2};
int not_copied = copy_to_user(to, from, sizeof(type) * 2);
It turns out not_copied is 0, even when I try using malloc for the "type to" declaration. Also, 'to[0]' and 'to[1]' are 'something1' and 'something2' respectively.
Am I right in thinking my declaration of 'type to' isn't restricting copy_to_user destination's memory as intended?
And how do I make it fail?
thanks.