Print this page
11838 secflag tests are racy
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
1 1 #! /usr/bin/ksh
2 2 #
3 3 #
4 4 # This file and its contents are supplied under the terms of the
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
6 6 # You may only use this file in accordance with the terms of version
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13
14 14 #
15 15 # Copyright 2015, Richard Lowe.
16 +# Copyright 2019 Joyent, Inc.
16 17 #
17 18
18 19 mkdir /tmp/secflags-test.$$
19 20 cd /tmp/secflags-test.$$
20 21
21 22 /usr/bin/psecflags -s aslr -e sleep 100000 &
22 23 pid=$!
23 24 coreadm -p core $pid # We need to be able to reliably find the core
24 25
25 26 cleanup() {
26 27 kill $pid >/dev/null 2>&1
27 28 cd /
28 29 rm -fr /tmp/secflags-test.$$
29 30 }
30 31
31 32 trap cleanup EXIT
32 33
34 +# We need to wait for sleep to get exec()ed
35 +sleep 1
36 +
33 37 ## gcore-produced core
34 38 gcore $pid >/dev/null
35 39
36 40 cat > gcore-expected.$$ <<EOF
37 41 namesz: 0x5
38 42 descsz: 0x28
39 43 type: [ NT_SECFLAGS ]
40 44 name:
41 45 CORE\0
42 46 desc: (prsecflags_t)
43 47 pr_version: 1
44 48 pr_effective: [ ASLR ]
45 49 pr_inherit: [ ASLR ]
46 50 pr_lower: 0
47 51 pr_upper: [ ASLR FORBIDNULLMAP NOEXECSTACK ]
48 52 EOF
49 53
50 54 /usr/bin/elfdump -n core.${pid} | grep -B5 -A5 prsecflags_t > gcore-output.$$
51 55
52 56 if ! diff -u gcore-expected.$$ gcore-output.$$; then
53 57 exit 1;
54 58 fi
55 59
56 60 ## kernel-produced core
57 61 kill -SEGV $pid
58 62 wait $pid >/dev/null 2>&1
59 63
60 64 cat > core-expected.$$ <<EOF
61 65 namesz: 0x5
62 66 descsz: 0x28
63 67 type: [ NT_SECFLAGS ]
64 68 name:
65 69 CORE\0
66 70 desc: (prsecflags_t)
67 71 pr_version: 1
68 72 pr_effective: [ ASLR ]
69 73 pr_inherit: [ ASLR ]
70 74 pr_lower: 0
71 75 pr_upper: [ ASLR FORBIDNULLMAP NOEXECSTACK ]
72 76 EOF
73 77
74 78 /usr/bin/elfdump -n core | grep -B5 -A5 prsecflags_t > core-output.$$
75 79
76 80 if ! diff -u core-expected.$$ core-output.$$; then
77 81 exit 1;
78 82 fi
79 83
80 84 exit 0
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX