-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[compiler-rt][sanitizer_common] copy_file_range syscall interception. #125816
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
@llvm/pr-subscribers-compiler-rt-sanitizer Author: David CARLIER (devnexen) ChangesFull diff: https://github.com/llvm/llvm-project/pull/125816.diff 2 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 29fe4721ba40dc..b68b3c2ba86fea 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -3205,6 +3205,26 @@ POST_SYSCALL(futex)
COMMON_SYSCALL_BLOCKING_END();
}
+PRE_SYSCALL(copy_file_range)
+(int fdin, __sanitizer___kernel_off_t *offin, int fdout, __sanitizer___kernel_off_t *offout, SIZE_T size, unsigned int flags) {
+ if (offin != nullptr) {
+ PRE_READ(offin, sizeof(*offin));
+ }
+ if (offout != nullptr) {
+ PRE_READ(offout, sizeof(*offout));
+ }
+}
+
+POST_SYSCALL(copy_file_range)
+(SSIZE_T, int fdin, __sanitizer___kernel_off_t *offin, int fdout, __sanitizer___kernel_off_t *offout, SIZE_T size, unsigned int flags) {
+ if (offin != nullptr) {
+ POST_WRITE(offin, sizeof(*offin));
+ }
+ if (offout != nullptr) {
+ POST_WRITE(offout, sizeof(*offout));
+ }
+}
+
} // extern "C"
# undef PRE_SYSCALL
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/copy_file_range.c b/compiler-rt/test/sanitizer_common/TestCases/Linux/copy_file_range.c
new file mode 100644
index 00000000000000..a53e6773cf2892
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/copy_file_range.c
@@ -0,0 +1,40 @@
+// RUN: %clangxx -O0 %s -o %t
+
+// REQUIRES: glibc
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <assert.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#if !defined(__GLIBC_PREREQ)
+#define __GLIBC_PREREQ(a, b) 0
+#endif
+
+#if !__GLIBC_PREREQ(2, 27)
+#define copy_file_range(a, b, c, d, e) (ssize_t)syscall(__NR_copy_file_range, a, b, c, d, e)
+#endif
+
+int main(void) {
+ int fdin = open("/proc/self/maps", O_RDONLY);
+ assert(fdin > 0);
+ char tmp[] = "/tmp/map.XXXXXX";
+ int fdout = mkstemp(tmp);
+ assert(fdout > 0);
+ off_t offin = -1, offout = 0;
+ ssize_t cpy = copy_file_range(fdin, &offin, fdout, &offout, 8, 0);
+ assert(cpy < 0);
+ offin = 0;
+ offout = 16;
+ cpy = copy_file_range(fdin, &offin, fdout, &offout, 8, 0);
+ assert(cpy < 0);
+ offout = 0;
+ cpy = copy_file_range(fdin, &offin, fdout, &offout, 8, 0);
+ assert(cpy == 8);
+ close(fdout);
+ close(fdin);
+ return 0;
+}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
2ae9928
to
65131bf
Compare
65131bf
to
4cd82e3
Compare
buildbot issue here. Looking. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/10465 Here is the relevant piece of the build log for the reference
|
Passing Large File Support. Address #125816
This broke the compiler-rt build for the Fuchsia Linux toolchain. This was not fixed by the follow-up patch. Accordingly, I'm issuing a revert.
|
I see ... seems to me it is a matter of missing argument in the macro ? |
…rception. (llvm#125816)" and fix This reverts commit e5d9310.
Yes, but I wasn't sure what the intended semantics were, otherwise I would have fixed forward. |
Passing Large File Support. Address llvm#125816
No description provided.