Skip to content

Commit

Permalink
fix sigreturn etc
Browse files Browse the repository at this point in the history
  • Loading branch information
thehajime committed Dec 11, 2024
1 parent 5d192bf commit ed6067b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/um/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ void do_signal(struct pt_regs *regs)
struct ksignal ksig;
int handled_sig = 0;

if (regs->regs.gp[15] == 58)
return;

while (get_signal(&ksig)) {
handled_sig = 1;
/* Whee! Actually deliver the signal. */
Expand Down
12 changes: 12 additions & 0 deletions arch/x86/um/nommu/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,25 @@ ENTRY(__kernel_vsyscall)

POP_REGS

cmpq $15, (%rsp)
je sigret

addq $8, %rsp /* skip orig_ax */
addq $8, %rsp /* skip ip */
addq $8, %rsp /* skip cs */
addq $8, %rsp /* skip flags */
popq %rsp

ret
sigret:
addq $8, %rsp /* skip orig_ax */
popq %r11 /* ip */
addq $8, %rsp /* skip cs */
addq $8, %rsp /* skip flags */
popq %rsp
//jmpq *%r11
pushq %r11
ret

END(__kernel_vsyscall)

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/um/nommu/os-Linux/mcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include <sysdep/mcontext.h>
#include <sysdep/syscalls.h>

extern void userspace(struct uml_pt_regs *regs);
static void userspace_sigreturn(void)
{
__asm__ volatile("movq $15, %rax");
__asm__ volatile("call *%0" : : "r"(__kernel_vsyscall) :);
// __asm__ volatile("call *%0" : : "r"(userspace) :);
}

void mc_set_regs_ip_relay(mcontext_t *mc)
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/um/nommu/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ int arch_setup_signal_stack_si(struct rt_sigframe __user **frame,
{
int err = 0;

if (sigismember(&ksig->ka.sa.sa_mask, ksig->sig)) {
pr_warn("signal masked");
return 0;
}
/*
* we need to push handler address at top of stack, as
* __kernel_vsyscall, called after this returns with ret with
Expand Down

0 comments on commit ed6067b

Please sign in to comment.