s390/syscalls: add spectre boundry for syscall dispatch table
PATCH 1/1 s390/syscalls: add spectre boundry for syscall dispatch table
The s390 syscall number is directly controlled by userspace, but does not have a array_index_nospec() boundry 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]>
Cc stable <[email protected]>
Assisted-by gkh_clanker_2000
Signed-off-by Greg Kroah-Hartman <[email protected]>
---
My scripts caught this as I think s390 is vulnerable to the old-style Spectre 1 issues, but I couldn't find where it was addressed in the syscall path. Did I just miss it somewhere, or is this patch still needed?
arch/s390/kernel/syscall.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/s390/kernel/syscall.c +4 -1
@@ -13,6 +13,7 @@*/ #include <linux/cpufeature.h> +#include <linux/nospec.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -131,8 +132,10 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)if (unlikely (test_and_clear_pt_regs_flag (regs,PIF_SYSCALL_RET_SET ))) goto out; regs->gprs[2 ] = -ENOSYS ; -if (likely (nr < NR_syscalls)) +if (likely (nr < NR_syscalls)) { + nr =array_index_nospec (nr, NR_syscalls); regs->gprs[2 ] = sys_call_table[nr](regs); + } out:syscall_exit_to_user_mode (regs); }
Signature · 1 line
2.53.0