Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch: Reserve map_shadow_stack() syscall number for all architectures

commit c35559f94ebc ("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: Sohil Mehta <sohil.mehta@intel.com>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Sohil Mehta and committed by
Arnd Bergmann
2fd0ebad ccab211a

+21 -2
+1
arch/alpha/kernel/syscalls/syscall.tbl
··· 492 492 560 common set_mempolicy_home_node sys_ni_syscall 493 493 561 common cachestat sys_cachestat 494 494 562 common fchmodat2 sys_fchmodat2 495 + 563 common map_shadow_stack sys_map_shadow_stack
+1
arch/arm/tools/syscall.tbl
··· 466 466 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 467 467 451 common cachestat sys_cachestat 468 468 452 common fchmodat2 sys_fchmodat2 469 + 453 common map_shadow_stack sys_map_shadow_stack
+1 -1
arch/arm64/include/asm/unistd.h
··· 39 39 #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5) 40 40 #define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) 41 41 42 - #define __NR_compat_syscalls 453 42 + #define __NR_compat_syscalls 454 43 43 #endif 44 44 45 45 #define __ARCH_WANT_SYS_CLONE
+2
arch/arm64/include/asm/unistd32.h
··· 911 911 __SYSCALL(__NR_cachestat, sys_cachestat) 912 912 #define __NR_fchmodat2 452 913 913 __SYSCALL(__NR_fchmodat2, sys_fchmodat2) 914 + #define __NR_map_shadow_stack 453 915 + __SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack) 914 916 915 917 /* 916 918 * Please add new compat syscalls above this comment and update
+1
arch/m68k/kernel/syscalls/syscall.tbl
··· 452 452 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 453 453 451 common cachestat sys_cachestat 454 454 452 common fchmodat2 sys_fchmodat2 455 + 453 common map_shadow_stack sys_map_shadow_stack
+1
arch/microblaze/kernel/syscalls/syscall.tbl
··· 458 458 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 459 459 451 common cachestat sys_cachestat 460 460 452 common fchmodat2 sys_fchmodat2 461 + 453 common map_shadow_stack sys_map_shadow_stack
+1
arch/mips/kernel/syscalls/syscall_n32.tbl
··· 391 391 450 n32 set_mempolicy_home_node sys_set_mempolicy_home_node 392 392 451 n32 cachestat sys_cachestat 393 393 452 n32 fchmodat2 sys_fchmodat2 394 + 453 n32 map_shadow_stack sys_map_shadow_stack
+1
arch/mips/kernel/syscalls/syscall_n64.tbl
··· 367 367 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 368 368 451 n64 cachestat sys_cachestat 369 369 452 n64 fchmodat2 sys_fchmodat2 370 + 453 n64 map_shadow_stack sys_map_shadow_stack
+1
arch/mips/kernel/syscalls/syscall_o32.tbl
··· 440 440 450 o32 set_mempolicy_home_node sys_set_mempolicy_home_node 441 441 451 o32 cachestat sys_cachestat 442 442 452 o32 fchmodat2 sys_fchmodat2 443 + 453 o32 map_shadow_stack sys_map_shadow_stack
+1
arch/parisc/kernel/syscalls/syscall.tbl
··· 451 451 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 452 452 451 common cachestat sys_cachestat 453 453 452 common fchmodat2 sys_fchmodat2 454 + 453 common map_shadow_stack sys_map_shadow_stack
+1
arch/powerpc/kernel/syscalls/syscall.tbl
··· 539 539 450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node 540 540 451 common cachestat sys_cachestat 541 541 452 common fchmodat2 sys_fchmodat2 542 + 453 common map_shadow_stack sys_ni_syscall
+1
arch/s390/kernel/syscalls/syscall.tbl
··· 455 455 450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node 456 456 451 common cachestat sys_cachestat sys_cachestat 457 457 452 common fchmodat2 sys_fchmodat2 sys_fchmodat2 458 + 453 common map_shadow_stack sys_map_shadow_stack sys_map_shadow_stack
+1
arch/sh/kernel/syscalls/syscall.tbl
··· 455 455 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 456 456 451 common cachestat sys_cachestat 457 457 452 common fchmodat2 sys_fchmodat2 458 + 453 common map_shadow_stack sys_map_shadow_stack
+1
arch/sparc/kernel/syscalls/syscall.tbl
··· 498 498 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 499 499 451 common cachestat sys_cachestat 500 500 452 common fchmodat2 sys_fchmodat2 501 + 453 common map_shadow_stack sys_map_shadow_stack
+1
arch/x86/entry/syscalls/syscall_32.tbl
··· 457 457 450 i386 set_mempolicy_home_node sys_set_mempolicy_home_node 458 458 451 i386 cachestat sys_cachestat 459 459 452 i386 fchmodat2 sys_fchmodat2 460 + 453 i386 map_shadow_stack sys_map_shadow_stack
+1
arch/xtensa/kernel/syscalls/syscall.tbl
··· 423 423 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 424 424 451 common cachestat sys_cachestat 425 425 452 common fchmodat2 sys_fchmodat2 426 + 453 common map_shadow_stack sys_map_shadow_stack
+4 -1
include/uapi/asm-generic/unistd.h
··· 823 823 #define __NR_fchmodat2 452 824 824 __SYSCALL(__NR_fchmodat2, sys_fchmodat2) 825 825 826 + #define __NR_map_shadow_stack 453 827 + __SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack) 828 + 826 829 #undef __NR_syscalls 827 - #define __NR_syscalls 453 830 + #define __NR_syscalls 454 828 831 829 832 /* 830 833 * 32 bit systems traditionally used different