glibc/v2-0011-x86-64-Add-fixup-asm-unistd.h-and-regenerate-arch.patch
Siddhesh Poyarekar 144f612406 Shadow stack userspace support
Downstream only and disabled by default.
2023-06-08 13:31:34 -04:00

97 lines
3.7 KiB
Diff

From da84f75756ca022e84be6fefd2b8167852949612 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 7 Jan 2022 14:31:25 -0800
Subject: [PATCH v2 11/15] x86-64: Add <fixup-asm-unistd.h> and regenerate
arch-syscall.h
Add the map_shadow_stack system call to Linux/x86-64.
---
sysdeps/unix/sysv/linux/syscall-names.list | 1 +
.../unix/sysv/linux/x86_64/64/arch-syscall.h | 1 +
.../sysv/linux/x86_64/64/fixup-asm-unistd.h | 20 +++++++++++++++++++
.../unix/sysv/linux/x86_64/x32/arch-syscall.h | 1 +
.../sysv/linux/x86_64/x32/fixup-asm-unistd.h | 4 ++++
5 files changed, 27 insertions(+)
create mode 100644 sysdeps/unix/sysv/linux/x86_64/64/fixup-asm-unistd.h
diff --git a/sysdeps/unix/sysv/linux/syscall-names.list b/sysdeps/unix/sysv/linux/syscall-names.list
index 5d27b5279c..2bb924c8c4 100644
--- a/sysdeps/unix/sysv/linux/syscall-names.list
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -245,6 +245,7 @@ lsetxattr
lstat
lstat64
madvise
+map_shadow_stack
mbind
membarrier
memfd_create
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/arch-syscall.h b/sysdeps/unix/sysv/linux/x86_64/64/arch-syscall.h
index b4ab892ec1..c09890ab74 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/x86_64/64/arch-syscall.h
@@ -152,6 +152,7 @@
#define __NR_lsetxattr 189
#define __NR_lstat 6
#define __NR_madvise 28
+#define __NR_map_shadow_stack 451
#define __NR_mbind 237
#define __NR_membarrier 324
#define __NR_memfd_create 319
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/fixup-asm-unistd.h b/sysdeps/unix/sysv/linux/x86_64/64/fixup-asm-unistd.h
new file mode 100644
index 0000000000..20d941796d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/64/fixup-asm-unistd.h
@@ -0,0 +1,20 @@
+/* Regularize <asm/unistd.h> definitions. X86-64/64 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __NR_map_shadow_stack
+# define __NR_map_shadow_stack 451
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h b/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h
index 772559c87b..7ad88cb20d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h
@@ -146,6 +146,7 @@
#define __NR_lsetxattr 1073742013
#define __NR_lstat 1073741830
#define __NR_madvise 1073741852
+#define __NR_map_shadow_stack 1073742275
#define __NR_mbind 1073742061
#define __NR_membarrier 1073742148
#define __NR_memfd_create 1073742143
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h b/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h
index ae854321a2..882a2ad8c8 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h
@@ -15,6 +15,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef __NR_map_shadow_stack
+# define __NR_map_shadow_stack 1073742275
+#endif
+
/* X32 uses the same 64-bit syscall interface for set_thread_area. */
#ifndef __NR_set_thread_area
# define __NR_set_thread_area 1073742029
--
2.40.1