s390: restore address space when returning to user space
Unbalanced set_fs usages (e.g. early exit from a function and a forgotten set_fs(USER_DS) call) may lead to a situation where the secondary asce is the kernel space asce when returning to user space. This would allow user space to modify kernel space at will. This would only be possible with the above mentioned kernel bug, however we can detect this and fix the secondary asce before returning to user space. Therefore a new TIF_ASCE_SECONDARY which is used within set_fs. When returning to user space check if TIF_ASCE_SECONDARY is set, which would indicate a bug. If it is set print a message to the console, fixup the secondary asce, and then return to user space. This is similar to what is being discussed for x86 and arm: "[RFC] syscalls: Restore address limit after a syscall". Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
committed by
Martin Schwidefsky
parent
606aa4aa0b
commit
b5a882fcf1
@ -234,3 +234,16 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
|
||||
ret = PAGE_ALIGN(mm->brk + brk_rnd());
|
||||
return (ret > mm->brk) ? ret : mm->brk;
|
||||
}
|
||||
|
||||
void set_fs_fixup(void)
|
||||
{
|
||||
struct pt_regs *regs = current_pt_regs();
|
||||
static bool warned;
|
||||
|
||||
set_fs(USER_DS);
|
||||
if (warned)
|
||||
return;
|
||||
WARN(1, "Unbalanced set_fs - int code: 0x%x\n", regs->int_code);
|
||||
show_registers(regs);
|
||||
warned = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user