[libc-commits] [libc] [libc] fortify jmp buffer for x86-64 (PR #112769)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Dec 2 13:23:23 PST 2024
================
@@ -0,0 +1,95 @@
+//===-- Implementation of longjmp (64-bit) --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "include/llvm-libc-macros/offsetof-macro.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/setjmp/longjmp.h"
+
+#if !defined(LIBC_TARGET_ARCH_IS_X86_64) || !LIBC_COPT_SETJMP_FORTIFICATION
+#error "Invalid file include"
+#endif
+
+#include "src/setjmp/checksum.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, longjmp, (jmp_buf, int)) {
+ asm(R"(
+ mov %c[rbx](%%rdi), %%rbx
+ xor %%rbx, %[cookie]
+ xor %[mask], %%rbx
----------------
nickdesaulniers wrote:
This is going to modify `mask`, right? In that case, I'd make `mask` an output that's also read `"+m"`, rather than an input. Same for setjmp.
https://github.com/llvm/llvm-project/pull/112769
More information about the libc-commits
mailing list