Print this page
11903 secflags_elfdump.sh test needs coreadm setting

Split Close
Expand all
Collapse all
          --- old/usr/src/test/os-tests/tests/secflags/secflags_elfdump.sh
          +++ new/usr/src/test/os-tests/tests/secflags/secflags_elfdump.sh
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14  #
  15   15  # Copyright 2015, Richard Lowe.
  16   16  # Copyright 2019 Joyent, Inc.
  17   17  #
  18   18  
  19   19  mkdir /tmp/secflags-test.$$
  20   20  cd /tmp/secflags-test.$$
  21   21  
  22   22  /usr/bin/psecflags -s aslr -e sleep 100000 &
  23   23  pid=$!
  24      -coreadm -p core $pid # We need to be able to reliably find the core
       24 +# Make sure we generate a kernel core we can find
       25 +coreadm -p core $pid
       26 +enabled=$(/usr/bin/svcprop -p config_params/process_enabled coreadm)
       27 +coreadm_restore=""
       28 +if [[ "$enabled" = "false" ]]; then
       29 +    coreadm_restore="/usr/bin/coreadm -d process"
       30 +    coreadm -e process
       31 +fi
  25   32  
  26   33  cleanup() {
  27   34      kill $pid >/dev/null 2>&1
  28   35      cd /
  29   36      rm -fr /tmp/secflags-test.$$
       37 +
       38 +    $coreadm_restore
  30   39  }
  31   40  
  32   41  trap cleanup EXIT
  33   42  
  34   43  # We need to wait for sleep to get exec()ed
  35   44  sleep 1
  36   45  
  37   46  ## gcore-produced core
  38   47  gcore $pid >/dev/null
  39   48  
↓ open down ↓ 7 lines elided ↑ open up ↑
  47   56          pr_version:    1
  48   57          pr_effective:  [ ASLR ]
  49   58          pr_inherit:    [ ASLR ]
  50   59          pr_lower:      0
  51   60          pr_upper:      [ ASLR FORBIDNULLMAP NOEXECSTACK ]
  52   61  EOF
  53   62  
  54   63  /usr/bin/elfdump -n core.${pid} | grep -B5 -A5 prsecflags_t > gcore-output.$$
  55   64  
  56   65  if ! diff -u gcore-expected.$$ gcore-output.$$; then
       66 +    $coreadm_restore
  57   67      exit 1;
  58   68  fi
  59   69  
  60   70  ## kernel-produced core
  61   71  kill -SEGV $pid
  62   72  wait $pid >/dev/null 2>&1
       73 +$coreadm_restore
  63   74  
  64   75  cat > core-expected.$$ <<EOF
  65   76      namesz: 0x5
  66   77      descsz: 0x28
  67   78      type:   [ NT_SECFLAGS ]
  68   79      name:
  69   80          CORE\0
  70   81      desc: (prsecflags_t)
  71   82          pr_version:    1
  72   83          pr_effective:  [ ASLR ]
↓ open down ↓ 12 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX