Print this page
OS-3825 lxbrand rsyslogd abort on centos6
OS-4047 lxbrand vsyscall while SIGSEGV? on next trap we're handler-free!
Reviewed by: Bryan Cantrill <bryan@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/trap.c
          +++ new/usr/src/uts/i86pc/os/trap.c
↓ open down ↓ 24 lines elided ↑ open up ↑
  25   25  
  26   26  /*      Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
  27   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T   */
  28   28  /*              All Rights Reserved                             */
  29   29  /*                                                              */
  30   30  /*      Copyright (c) 1987, 1988 Microsoft Corporation          */
  31   31  /*              All Rights Reserved                             */
  32   32  /*                                                              */
  33   33  
  34   34  /*
  35      - * Copyright 2012 Joyent, Inc. All rights reserved.
       35 + * Copyright 2015 Joyent, Inc.
  36   36   */
  37   37  
  38   38  #include <sys/types.h>
  39   39  #include <sys/sysmacros.h>
  40   40  #include <sys/param.h>
  41   41  #include <sys/signal.h>
  42   42  #include <sys/systm.h>
  43   43  #include <sys/user.h>
  44   44  #include <sys/proc.h>
  45   45  #include <sys/disp.h>
↓ open down ↓ 48 lines elided ↑ open up ↑
  94   94  #include <sys/ontrap.h>
  95   95  #include <sys/cpc_impl.h>
  96   96  #include <sys/bootconf.h>
  97   97  #include <sys/bootinfo.h>
  98   98  #include <sys/promif.h>
  99   99  #include <sys/mach_mmu.h>
 100  100  #if defined(__xpv)
 101  101  #include <sys/hypervisor.h>
 102  102  #endif
 103  103  #include <sys/contract/process_impl.h>
      104 +#include <sys/brand.h>
 104  105  
 105  106  #define USER    0x10000         /* user-mode flag added to trap type */
 106  107  
 107  108  static const char *trap_type_mnemonic[] = {
 108  109          "de",   "db",   "2",    "bp",
 109  110          "of",   "br",   "ud",   "nm",
 110  111          "df",   "9",    "ts",   "np",
 111  112          "ss",   "gp",   "pf",   "15",
 112  113          "mf",   "ac",   "mc",   "xf"
 113  114  };
↓ open down ↓ 741 lines elided ↑ open up ↑
 855  856                                  break;
 856  857                          }
 857  858                  } else {
 858  859                          /* XXX pr_watch_emul() never succeeds (for now) */
 859  860                          if (rw != S_EXEC && pr_watch_emul(rp, vaddr, rw))
 860  861                                  goto out;
 861  862                          do_watch_step(vaddr, sz, rw, 0, 0);
 862  863                          fault_type = F_INVAL;
 863  864                  }
 864  865  
      866 +                /*
      867 +                 * Allow the brand to interpose on invalid memory accesses
      868 +                 * prior to running the native pagefault handler.  If this
      869 +                 * brand hook returns zero, it was able to handle the fault
      870 +                 * completely.  Otherwise, drive on and call pagefault().
      871 +                 */
      872 +                if (PROC_IS_BRANDED(p) && BROP(p)->b_pagefault != NULL &&
      873 +                    BROP(p)->b_pagefault(p, lwp, addr, fault_type, rw) == 0) {
      874 +                        goto out;
      875 +                }
      876 +
 865  877                  res = pagefault(addr, fault_type, rw, 0);
 866  878  
 867  879                  /*
 868  880                   * If pagefault() succeeded, ok.
 869  881                   * Otherwise attempt to grow the stack.
 870  882                   */
 871  883                  if (res == 0 ||
 872  884                      (res == FC_NOMAP &&
 873  885                      addr < p->p_usrstack &&
 874  886                      grow(addr))) {
↓ open down ↓ 1419 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX