Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libkern: Fix bcopy_c/memcpy_c handling of final capability
The use of > rather than >= meant that for capability-aligned ends the final capability was copied byte-wise, losing its tag, rather than as a capability. This bug has been present since the very first commit of this generic C version, but does not appear to have existed in the old CHERI-MIPS assembly version. Notably this breaks the DRM_IOCTL_VERSION ioctl, which has a capability as its final struct member, in hybrid kernels, since the memcpy_c used in drm_ioctl clears the tag on that member and then proceeds to EFAULT when trying to copy out to it. This gets even worse for libdrm since the mutated struct is then copied back out itself, and libdrm tries to free the pointer on error, which results in a tag fault.
- Loading branch information