The parameter to ioctl FICLONE is a file descriptor, as documented here: http://man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.html However, valgrind seems to believe that it should be a pointer, and complains that the pointer is not valid, saying: "Syscall param ioctl(generic) points to unaddressable byte(s)"
Created attachment 116351 [details] Patch to handle FICLONE ioctl on Linux
I've sent a patch to handle FICLONE correctly. It seems to me that the ioctl definition in Linux's uapi is misleading because it is set with a write direction but do not use the argument as a pointer (it is a file descriptor). Hence the error in the generic ioctl handler. It can be tested by running this command on a btrfs filesystem (might do it with another fs, haven't tested): valgrind cp --reflink=always example.txt example_copy.txt
I can confirm that the patch works and in would be nice to have in in the next Valgrind release. I've set up a PPA with the patch applied: https://launchpad.net/~rbalint/+archive/ubuntu/valgrind
Apologies this patch lingered so long. It does look correct, I replicated the issue and your analysis of how the _IOW uapi definition is misleading also seems correct. Pushed as: commit 1c49351424f04ee29a5efc054cb08ab3ad22b978 Author: Laurent Bonnans <laurent.bonnans@here.com> Date: Fri Nov 16 15:22:18 2018 +0100 Fix 397605 - Add support for Linux FICLONE ioctl