diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt index 42190079141b0..df85d44e9e9ed 100644 --- a/libc/src/unistd/linux/CMakeLists.txt +++ b/libc/src/unistd/linux/CMakeLists.txt @@ -283,6 +283,7 @@ add_entrypoint_object( libc.include.unistd libc.include.sys_syscall libc.src.__support.OSUtil.osutil + libc.src.__support.macros.sanitizer libc.src.errno.errno ) @@ -309,6 +310,7 @@ add_entrypoint_object( libc.include.unistd libc.include.sys_syscall libc.src.__support.OSUtil.osutil + libc.src.__support.macros.sanitizer libc.src.errno.errno ) diff --git a/libc/src/unistd/linux/pread.cpp b/libc/src/unistd/linux/pread.cpp index 614de9732c627..11cefc5c2f3a8 100644 --- a/libc/src/unistd/linux/pread.cpp +++ b/libc/src/unistd/linux/pread.cpp @@ -10,7 +10,7 @@ #include "src/__support/OSUtil/syscall.h" // For internal syscall function. #include "src/__support/common.h" - +#include "src/__support/macros/sanitizer.h" // for MSAN_UNPOISON #include "src/errno/libc_errno.h" #include // For uint64_t. #include // For syscall numbers. @@ -28,6 +28,9 @@ LLVM_LIBC_FUNCTION(ssize_t, pread, ssize_t ret = LIBC_NAMESPACE::syscall_impl(SYS_pread64, fd, buf, count, offset); #endif + // The cast is important since there is a check that dereferences the pointer + // which fails on void*. + MSAN_UNPOISON(reinterpret_cast(buf), count); if (ret < 0) { libc_errno = static_cast(-ret); return -1;