Commit 7527b2b3 authored by Sohil Mehta's avatar Sohil Mehta Committed by Wei Li
Browse files

arch: Reserve map_shadow_stack() syscall number for all architectures

mainline inclusion
from mainline-v6.7-rc1
commit 2fd0ebad27bcd4c8fc61c61a98d4283c47054bcf
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8YHN7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=2fd0ebad27bcd4c8fc61c61a98d4283c47054bcf

--------------------------------

commit c35559f9 ("x86/shstk: Introduce map_shadow_stack syscall")
recently added support for map_shadow_stack() but it is limited to x86
only for now. There is a possibility that other architectures (namely,
arm64 and RISC-V), that are implementing equivalent support for shadow
stacks, might need to add support for it.

Independent of that, reserving arch-specific syscall numbers in the
syscall tables of all architectures is good practice and would help
avoid future conflicts. map_shadow_stack() is marked as a conditional
syscall in sys_ni.c. Adding it to the syscall tables of other
architectures is harmless and would return ENOSYS when exercised.

Note, map_shadow_stack() was assigned #453 during the merge process
since #452 was taken by fchmodat2().

For Powerpc, map it to sys_ni_syscall() as is the norm for Powerpc
syscall tables.

For Alpha, map_shadow_stack() takes up #563 as Alpha still diverges from
the common syscall numbering system in the other architectures.

Link: https://lore.kernel.org/lkml/20230515212255.GA562920@debug.ba.rivosinc.com/
Link: https://lore.kernel.org/lkml/b402b80b-a7c6-4ef0-b977-c0f5f582b78a@sirena.org.uk/



Signed-off-by: default avatarSohil Mehta <sohil.mehta@intel.com>
Reviewed-by: default avatarRick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
[liwei: Sync with tools/* as well.]
Signed-off-by: default avatarWei Li <liwei391@huawei.com>
parent e076c150
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -492,3 +492,4 @@
560	common	set_mempolicy_home_node		sys_ni_syscall
561	common	cachestat			sys_cachestat
562	common	fchmodat2			sys_fchmodat2
563	common	map_shadow_stack		sys_map_shadow_stack
+1 −0
Original line number Diff line number Diff line
@@ -466,3 +466,4 @@
450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
451	common	cachestat			sys_cachestat
452	common	fchmodat2			sys_fchmodat2
453	common	map_shadow_stack		sys_map_shadow_stack
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@
#define __ARM_NR_compat_set_tls		(__ARM_NR_COMPAT_BASE + 5)
#define __ARM_NR_COMPAT_END		(__ARM_NR_COMPAT_BASE + 0x800)

#define __NR_compat_syscalls		453
#define __NR_compat_syscalls		454
#endif

#define __ARCH_WANT_SYS_CLONE
+2 −0
Original line number Diff line number Diff line
@@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
__SYSCALL(__NR_cachestat, sys_cachestat)
#define __NR_fchmodat2 452
__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
#define __NR_map_shadow_stack 453
__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)

/*
 * Please add new compat syscalls above this comment and update
+1 −0
Original line number Diff line number Diff line
@@ -452,3 +452,4 @@
450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
451	common	cachestat			sys_cachestat
452	common	fchmodat2			sys_fchmodat2
453	common	map_shadow_stack		sys_map_shadow_stack
Loading