um: pass siginfo to guest process
UML guest processes now get correct siginfo_t for SIGTRAP, SIGFPE, SIGILL and SIGBUS. Specifically, si_addr and si_code are now correct where previously they were si_addr = NULL and si_code = 128. Signed-off-by: Martin Pärtel <martin.partel@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:

committed by
Richard Weinberger

parent
d4afcba95f
commit
d3c1cfcdb4
@@ -13,8 +13,9 @@
|
||||
#include "kern_util.h"
|
||||
#include "os.h"
|
||||
#include "sysdep/mcontext.h"
|
||||
#include "internal.h"
|
||||
|
||||
void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
|
||||
void (*sig_info[NSIG])(int, siginfo_t *, struct uml_pt_regs *) = {
|
||||
[SIGTRAP] = relay_signal,
|
||||
[SIGFPE] = relay_signal,
|
||||
[SIGILL] = relay_signal,
|
||||
@@ -24,7 +25,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
|
||||
[SIGIO] = sigio_handler,
|
||||
[SIGVTALRM] = timer_handler };
|
||||
|
||||
static void sig_handler_common(int sig, mcontext_t *mc)
|
||||
static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc)
|
||||
{
|
||||
struct uml_pt_regs r;
|
||||
int save_errno = errno;
|
||||
@@ -40,7 +41,7 @@ static void sig_handler_common(int sig, mcontext_t *mc)
|
||||
if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
|
||||
unblock_signals();
|
||||
|
||||
(*sig_info[sig])(sig, &r);
|
||||
(*sig_info[sig])(sig, si, &r);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
@@ -60,7 +61,7 @@ static void sig_handler_common(int sig, mcontext_t *mc)
|
||||
static int signals_enabled;
|
||||
static unsigned int signals_pending;
|
||||
|
||||
void sig_handler(int sig, mcontext_t *mc)
|
||||
void sig_handler(int sig, siginfo_t *si, mcontext_t *mc)
|
||||
{
|
||||
int enabled;
|
||||
|
||||
@@ -72,7 +73,7 @@ void sig_handler(int sig, mcontext_t *mc)
|
||||
|
||||
block_signals();
|
||||
|
||||
sig_handler_common(sig, mc);
|
||||
sig_handler_common(sig, si, mc);
|
||||
|
||||
set_signals(enabled);
|
||||
}
|
||||
@@ -85,10 +86,10 @@ static void real_alarm_handler(mcontext_t *mc)
|
||||
get_regs_from_mc(®s, mc);
|
||||
regs.is_user = 0;
|
||||
unblock_signals();
|
||||
timer_handler(SIGVTALRM, ®s);
|
||||
timer_handler(SIGVTALRM, NULL, ®s);
|
||||
}
|
||||
|
||||
void alarm_handler(int sig, mcontext_t *mc)
|
||||
void alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
|
||||
{
|
||||
int enabled;
|
||||
|
||||
@@ -119,7 +120,7 @@ void set_sigstack(void *sig_stack, int size)
|
||||
panic("enabling signal stack failed, errno = %d\n", errno);
|
||||
}
|
||||
|
||||
static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = {
|
||||
static void (*handlers[_NSIG])(int sig, siginfo_t *si, mcontext_t *mc) = {
|
||||
[SIGSEGV] = sig_handler,
|
||||
[SIGBUS] = sig_handler,
|
||||
[SIGILL] = sig_handler,
|
||||
@@ -132,7 +133,7 @@ static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = {
|
||||
};
|
||||
|
||||
|
||||
static void hard_handler(int sig, siginfo_t *info, void *p)
|
||||
static void hard_handler(int sig, siginfo_t *si, void *p)
|
||||
{
|
||||
struct ucontext *uc = p;
|
||||
mcontext_t *mc = &uc->uc_mcontext;
|
||||
@@ -161,7 +162,7 @@ static void hard_handler(int sig, siginfo_t *info, void *p)
|
||||
while ((sig = ffs(pending)) != 0){
|
||||
sig--;
|
||||
pending &= ~(1 << sig);
|
||||
(*handlers[sig])(sig, mc);
|
||||
(*handlers[sig])(sig, si, mc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -273,9 +274,12 @@ void unblock_signals(void)
|
||||
* Deal with SIGIO first because the alarm handler might
|
||||
* schedule, leaving the pending SIGIO stranded until we come
|
||||
* back here.
|
||||
*
|
||||
* SIGIO's handler doesn't use siginfo or mcontext,
|
||||
* so they can be NULL.
|
||||
*/
|
||||
if (save_pending & SIGIO_MASK)
|
||||
sig_handler_common(SIGIO, NULL);
|
||||
sig_handler_common(SIGIO, NULL, NULL);
|
||||
|
||||
if (save_pending & SIGVTALRM_MASK)
|
||||
real_alarm_handler(NULL);
|
||||
|
Reference in New Issue
Block a user