Skip to content

Commit 48b8814

Browse files
gregkhVasily Gorbik
authored andcommitted
s390/syscalls: Add spectre boundary for syscall dispatch table
The s390 syscall number is directly controlled by userspace, but does not have an array_index_nospec() boundary to prevent access past the syscall function pointer tables. Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Arnd Bergmann <[email protected]> Fixes: 56e62a7 ("s390: convert to generic entry") Cc: [email protected] Assisted-by: gkh_clanker_2000 Signed-off-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Vasily Gorbik <[email protected]> Link: https://lore.kernel.org/r/2026032404-sterling-swoosh-43e6@gregkh Signed-off-by: Vasily Gorbik <[email protected]>
1 parent c5c0a26 commit 48b8814

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/s390/kernel/syscall.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <linux/cpufeature.h>
16+
#include <linux/nospec.h>
1617
#include <linux/errno.h>
1718
#include <linux/sched.h>
1819
#include <linux/mm.h>
@@ -131,8 +132,10 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
131132
if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
132133
goto out;
133134
regs->gprs[2] = -ENOSYS;
134-
if (likely(nr < NR_syscalls))
135+
if (likely(nr < NR_syscalls)) {
136+
nr = array_index_nospec(nr, NR_syscalls);
135137
regs->gprs[2] = sys_call_table[nr](regs);
138+
}
136139
out:
137140
syscall_exit_to_user_mode(regs);
138141
}

0 commit comments

Comments
 (0)