-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[libc] Unpoison epoll structs #94536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The epoll wait functions return structs via pointer, but those structs need to be unpoisoned before return. This patch adds that unpoisoning.
@llvm/pr-subscribers-libc Author: Michael Jones (michaelrj-google) ChangesThe epoll wait functions return structs via pointer, but those structs Full diff: https://github.com/llvm/llvm-project/pull/94536.diff 5 Files Affected:
diff --git a/libc/src/sys/epoll/linux/CMakeLists.txt b/libc/src/sys/epoll/linux/CMakeLists.txt
index 4e661b262b85b..5ba89bd1af603 100644
--- a/libc/src/sys/epoll/linux/CMakeLists.txt
+++ b/libc/src/sys/epoll/linux/CMakeLists.txt
@@ -48,6 +48,7 @@ add_entrypoint_object(
libc.hdr.types.struct_timespec
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
+ libc.src.__support.macros.sanitizer
libc.src.errno.errno
)
@@ -65,6 +66,7 @@ add_entrypoint_object(
libc.hdr.signal_macros
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
+ libc.src.__support.macros.sanitizer
libc.src.errno.errno
)
@@ -82,5 +84,6 @@ add_entrypoint_object(
libc.hdr.signal_macros
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
+ libc.src.__support.macros.sanitizer
libc.src.errno.errno
)
diff --git a/libc/src/sys/epoll/linux/epoll_pwait.cpp b/libc/src/sys/epoll/linux/epoll_pwait.cpp
index 8f498d18d547d..24b66f0721b30 100644
--- a/libc/src/sys/epoll/linux/epoll_pwait.cpp
+++ b/libc/src/sys/epoll/linux/epoll_pwait.cpp
@@ -13,6 +13,7 @@
#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/macros/sanitizer.h"
#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
@@ -33,6 +34,8 @@ LLVM_LIBC_FUNCTION(int, epoll_pwait,
return -1;
}
+ MSAN_UNPOISON(events, ret * sizeof(struct epoll_event));
+
return ret;
}
diff --git a/libc/src/sys/epoll/linux/epoll_pwait2.cpp b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
index bd33cb6325cea..e13423a085a59 100644
--- a/libc/src/sys/epoll/linux/epoll_pwait2.cpp
+++ b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
@@ -14,6 +14,7 @@
#include "hdr/types/struct_timespec.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/macros/sanitizer.h"
#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
@@ -35,6 +36,8 @@ LLVM_LIBC_FUNCTION(int, epoll_pwait2,
return -1;
}
+ MSAN_UNPOISON(events, ret * sizeof(struct epoll_event));
+
return ret;
}
diff --git a/libc/src/sys/epoll/linux/epoll_wait.cpp b/libc/src/sys/epoll/linux/epoll_wait.cpp
index 95238d872d52f..3ce4a92e79695 100644
--- a/libc/src/sys/epoll/linux/epoll_wait.cpp
+++ b/libc/src/sys/epoll/linux/epoll_wait.cpp
@@ -13,6 +13,7 @@
#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/macros/sanitizer.h"
#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
@@ -39,6 +40,8 @@ LLVM_LIBC_FUNCTION(int, epoll_wait,
return -1;
}
+ MSAN_UNPOISON(events, ret * sizeof(struct epoll_event));
+
return ret;
}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index f3809bd748140..96cc895559319 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1111,7 +1111,7 @@ libc_support_library(
],
defines = [
"LIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY",
- "LIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT"
+ "LIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT",
],
target_compatible_with = select({
"@platforms//os:linux": [],
@@ -1119,9 +1119,9 @@ libc_support_library(
}),
deps = [
":__support_cpp_optional",
- ":__support_time_linux",
":__support_threads_linux_futex_utils",
":__support_threads_sleep",
+ ":__support_time_linux",
":types_pid_t",
],
)
@@ -3580,6 +3580,7 @@ libc_function(
}),
weak = True,
deps = [
+ ":__support_macros_sanitizer",
":__support_osutil_syscall",
":errno",
":hdr_signal_macros",
@@ -3599,6 +3600,7 @@ libc_function(
}),
weak = True,
deps = [
+ ":__support_macros_sanitizer",
":__support_osutil_syscall",
":errno",
":hdr_signal_macros",
@@ -3620,6 +3622,7 @@ libc_function(
# }),
# weak = True,
# deps = [
+# ":__support_macros_sanitizer",
# ":__support_osutil_syscall",
# ":errno",
# ":hdr_signal_macros",
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix!
LGTM
The epoll wait functions return structs via pointer, but those structs
need to be unpoisoned before return. This patch adds that unpoisoning.