ioctl(sock, SIOCATMARK, arg) is invalid if sock is a UDP socket, as SIOCATMARK is only supported for TCP sockets. In the case where the protocol doesn't recognise the command, sock_do_ioctl() (net/socket.c) attempts to hand it down to the NIC driver, and for that purpose interprets arg as a pointer to struct ifreq. However, since we are passing a pointer to int, which is smaller than struct ifreq, the kernel will attempt to read beyond the bounds of the specified capability pointer in purecap, resulting in -EFAULT instead of the expected -EINVAL.
Given that what arg actually points to is irrelevant to that testcase, let's just use a capability with large enough bounds, namely &if, to avoid getting -EFAULT in purecap.
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- testcases/kernel/syscalls/sockioctl/sockioctl01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/sockioctl/sockioctl01.c b/testcases/kernel/syscalls/sockioctl/sockioctl01.c index 6ba39faae0e2..96ff9d14446e 100644 --- a/testcases/kernel/syscalls/sockioctl/sockioctl01.c +++ b/testcases/kernel/syscalls/sockioctl/sockioctl01.c @@ -101,7 +101,7 @@ struct test_case_t { , #endif { - PF_INET, SOCK_DGRAM, 0, SIOCATMARK, &optval, + PF_INET, SOCK_DGRAM, 0, SIOCATMARK, &ifr, (struct sockaddr *)&fsin1, sizeof(fsin1), -1, EINVAL, setup1, cleanup1, "ATMARK on UDP"} , {