mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
MIPS: Sanitize restart logics
Put the original syscall number into ->regs[0] when we leave syscall with error. Use it in restart logics. Everything else will have it 0 since we pass through SAVE_SOME on all the ways in. Note that in places like bad_stack and inllegal_syscall we leave it 0 - it's not restartable. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Cc: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/1698/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
e5b377a8fb
commit
8f5a00eb42
7 changed files with 34 additions and 35 deletions
|
@ -550,23 +550,26 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
|
|||
struct mips_abi *abi = current->thread.abi;
|
||||
void *vdso = current->mm->context.vdso;
|
||||
|
||||
switch(regs->regs[0]) {
|
||||
case ERESTART_RESTARTBLOCK:
|
||||
case ERESTARTNOHAND:
|
||||
regs->regs[2] = EINTR;
|
||||
break;
|
||||
case ERESTARTSYS:
|
||||
if (!(ka->sa.sa_flags & SA_RESTART)) {
|
||||
if (regs->regs[0]) {
|
||||
switch(regs->regs[2]) {
|
||||
case ERESTART_RESTARTBLOCK:
|
||||
case ERESTARTNOHAND:
|
||||
regs->regs[2] = EINTR;
|
||||
break;
|
||||
case ERESTARTSYS:
|
||||
if (!(ka->sa.sa_flags & SA_RESTART)) {
|
||||
regs->regs[2] = EINTR;
|
||||
break;
|
||||
}
|
||||
/* fallthrough */
|
||||
case ERESTARTNOINTR:
|
||||
regs->regs[7] = regs->regs[26];
|
||||
regs->regs[2] = regs->regs[0];
|
||||
regs->cp0_epc -= 4;
|
||||
}
|
||||
/* fallthrough */
|
||||
case ERESTARTNOINTR: /* Userland will reload $v0. */
|
||||
regs->regs[7] = regs->regs[26];
|
||||
regs->cp0_epc -= 8;
|
||||
}
|
||||
|
||||
regs->regs[0] = 0; /* Don't deal with this again. */
|
||||
regs->regs[0] = 0; /* Don't deal with this again. */
|
||||
}
|
||||
|
||||
if (sig_uses_siginfo(ka))
|
||||
ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset,
|
||||
|
@ -625,17 +628,13 @@ static void do_signal(struct pt_regs *regs)
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Who's code doesn't conform to the restartable syscall convention
|
||||
* dies here!!! The li instruction, a single machine instruction,
|
||||
* must directly be followed by the syscall instruction.
|
||||
*/
|
||||
if (regs->regs[0]) {
|
||||
if (regs->regs[2] == ERESTARTNOHAND ||
|
||||
regs->regs[2] == ERESTARTSYS ||
|
||||
regs->regs[2] == ERESTARTNOINTR) {
|
||||
regs->regs[2] = regs->regs[0];
|
||||
regs->regs[7] = regs->regs[26];
|
||||
regs->cp0_epc -= 8;
|
||||
regs->cp0_epc -= 4;
|
||||
}
|
||||
if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
|
||||
regs->regs[2] = current->thread.abi->restart;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue