s390: add no-execute support
Bit 0x100 of a page table, segment table of region table entry can be used to disallow code execution for the virtual addresses associated with the entry. There is one tricky bit, the system call to return from a signal is part of the signal frame written to the user stack. With a non-executable stack this would stop working. To avoid breaking things the protection fault handler checks the opcode that caused the fault for 0x0a77 (sys_sigreturn) and 0x0aad (sys_rt_sigreturn) and injects a system call. This is preferable to the alternative solution with a stub function in the vdso because it works for vdso=off and statically linked binaries as well. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
@@ -354,6 +354,10 @@ static __init void detect_machine_facilities(void)
|
||||
S390_lowcore.machine_flags |= MACHINE_FLAG_VX;
|
||||
__ctl_set_bit(0, 17);
|
||||
}
|
||||
if (test_facility(130)) {
|
||||
S390_lowcore.machine_flags |= MACHINE_FLAG_NX;
|
||||
__ctl_set_bit(0, 20);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void save_vector_registers(void)
|
||||
@@ -384,6 +388,21 @@ static int __init disable_vector_extension(char *str)
|
||||
}
|
||||
early_param("novx", disable_vector_extension);
|
||||
|
||||
static int __init noexec_setup(char *str)
|
||||
{
|
||||
bool enabled;
|
||||
int rc;
|
||||
|
||||
rc = kstrtobool(str, &enabled);
|
||||
if (!rc && !enabled) {
|
||||
/* Disable no-execute support */
|
||||
S390_lowcore.machine_flags &= ~MACHINE_FLAG_NX;
|
||||
__ctl_clear_bit(0, 20);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
early_param("noexec", noexec_setup);
|
||||
|
||||
static int __init cad_setup(char *str)
|
||||
{
|
||||
int val;
|
||||
|
Reference in New Issue
Block a user