Beispiel #1
0
enum NaClSignalResult NaClSignalHandleUntrusted(int signal, void *ctx) {
  struct NaClSignalContext sigCtx;
  char tmp[128];
  /*
   * Return an 8 bit error code which is -signal to
   * simulate normal OS behavior
   */
  NaClSignalContextFromHandler(&sigCtx, ctx);
  if (NaClSignalContextIsUntrusted(&sigCtx)) {
    SNPRINTF(tmp, sizeof(tmp), "\n** Signal %d from untrusted code: Halting "
             "at %" NACL_PRIXNACL_REG "h\n", signal, sigCtx.prog_ctr);
    NaClSignalErrorMessage(tmp);
    NaClExit((-signal) & 0xFF);
  }
  else {
    SNPRINTF(tmp, sizeof(tmp), "\n** Signal %d from trusted code: Continuing "
             "from %" NACL_PRIXNACL_REG "h\n", signal, sigCtx.prog_ctr);
    NaClSignalErrorMessage(tmp);
  }
  return NACL_SIGNAL_SEARCH;
}
Beispiel #2
0
/*
 * A basic handler which will exit with -signal_number when
 * a signal is encountered.
 */
static enum NaClSignalResult NaClSignalHandleAll(int signum, void *ctx)
{
  struct NaClSignalContext sigCtx;
  char msg[SIGNAL_STRLEN];

  /* todo(d'b): is it proper solution? */
  static int busy = 0;
  if(busy) return NACL_SIGNAL_RETURN;
  busy = 1;

  /*
   * Return an 8 bit error code which is -signal to
   * simulate normal OS behavior
   */
  NaClSignalContextFromHandler(&sigCtx, ctx);

  /* set zvm state */
  g_snprintf(msg, SIGNAL_STRLEN, "Signal %d from %strusted code: Halting at 0x%012lX",
      signum, NaClSignalContextIsUntrusted(&sigCtx) ? "un" : "", sigCtx.prog_ctr);
  SetExitState(msg);

  NaClExit(EINTR);
  return NACL_SIGNAL_RETURN; /* unreachable */
}
void NaClAppThreadGetSuspendedRegistersInternal(
    struct NaClAppThread *natp, struct NaClSignalContext *regs) {
  NaClSignalContextFromHandler(regs, natp->suspended_registers);
}