| 1 |
<!DOCTYPE html> |
| 2 |
<!-- |
| 3 |
This document is Copyright 1996-2014 by George J. Carrette, |
| 4 |
All Rights Reserved. |
| 5 |
--> |
| 6 |
<html> |
| 7 |
<head><title>CRASHME: Random input testing.</title> |
| 8 |
<meta name="description" |
| 9 |
content="Using random input testing on the instruction set of a computation environment."/> |
| 10 |
<meta name="keywords" |
| 11 |
content="security, testing, robustness, cybernetics"/> |
| 12 |
</head> |
| 13 |
<body> |
| 14 |
<h1>CRASHME: Random input testing</h1> |
| 15 |
|
| 16 |
<p>Copyright 1996-2014 by George J. Carrette. All rights Reserved. |
| 17 |
</p> |
| 18 |
|
| 19 |
<p>See the source crashme.c for reports of system crashes. |
| 20 |
Software available: |
| 21 |
|
| 22 |
<ul> |
| 23 |
<li>Source tarball <a target="_blank" href="http://crashme.codeplex.com/releases/view/122163">crashme-2.7.tgz download page</a> |
| 24 |
</li> |
| 25 |
<li>Windows installer, source code (ZIP) for download, |
| 26 |
and subversion checkout, |
| 27 |
<a href="http://crashme.codeplex.com/">crashme.codeplex.com</a> |
| 28 |
</li> |
| 29 |
<li> |
| 30 |
<a href="downloads/crashme/">links to various versions</a> |
| 31 |
</li> |
| 32 |
</ul> |
| 33 |
|
| 34 |
</p> |
| 35 |
|
| 36 |
<p> |
| 37 |
Acknowledgements. |
| 38 |
</p> |
| 39 |
|
| 40 |
<p> |
| 41 |
Many people have provided suggestions and comments and |
| 42 |
feedback. Some in private email and some as published on the comp.arch |
| 43 |
newsgroups. But as the author of this gross hack I take full |
| 44 |
responsibility for any errors in the information presented. |
| 45 |
</p> |
| 46 |
|
| 47 |
<hr/> |
| 48 |
|
| 49 |
<p> |
| 50 |
|
| 51 |
A bit of background on crashme. It is a tool for testing the |
| 52 |
robustness of an operating environment using a technique of "Random |
| 53 |
Input" response analysis. This I first saw formally proposed in the |
| 54 |
book Cybernetics by Norbert Wiener, but which any parent who has |
| 55 |
observed his children playing and learning would be well disposed to |
| 56 |
describe in detail. |
| 57 |
<!-- Dead references unfortunately... |
| 58 |
There is a wealth of information on |
| 59 |
the web containing references to Mr Weiner and his work, |
| 60 |
see for example <a href="http://www.ams.org/publications/notices/199504/wiener.html">www.ams.org</a> or <a href="http://rleweb.mit.edu/g-atshst.htm">rleweb.mit.edu</a>. |
| 61 |
--> |
| 62 |
|
| 63 |
<ul> |
| 64 |
<li>The operating environment under consideration is the user-mode process.</li> |
| 65 |
|
| 66 |
<li>The Random Input is provided by the execution of a sequence of pseudo-random data as an instruction stream.</li> |
| 67 |
|
| 68 |
<li>The response analysis is to catch and record machine and software |
| 69 |
generated exceptions/errors/signals and to retry using new random data |
| 70 |
in both the current user-mode process and in newly created |
| 71 |
subprocesses.</li> |
| 72 |
|
| 73 |
</ul> |
| 74 |
|
| 75 |
<hr/> |
| 76 |
</p> |
| 77 |
|
| 78 |
<p>Notes for release 2.2 of Crashme. 9-MAY-1994 [email protected] |
| 79 |
</p> |
| 80 |
|
| 81 |
<p>Added the X.Y syntax for the NBYTES argument. This may run faster, |
| 82 |
doing more tests per second. A reasonable value for Y would be |
| 83 |
the number of bytes in a machine instruction. |
| 84 |
</p> |
| 85 |
|
| 86 |
<p>Many people have suggested that the output of previous versions was |
| 87 |
far too verbose, and that that was not only annoying but also |
| 88 |
effectively slowing down the program. Therefore there is a new argument |
| 89 |
available after the subprocess control argument, which is a verboseness |
| 90 |
level from 0 to 5. Using a level of 2 will print out only summary |
| 91 |
information about the runs. e.g. |
| 92 |
|
| 93 |
<blockquote><pre><tt> |
| 94 |
$ crashme +2000 666 50 00:30:00 2 |
| 95 |
Crashme: (c) Copyright 1990, 1991 George J. Carrette |
| 96 |
Version: 1.7 25-SEP-1991 |
| 97 |
Subprocess run for 1800 seconds (0 00:30:00) |
| 98 |
Test complete, total real time: 1801 seconds (0 00:30:01) |
| 99 |
exit status ... number of cases |
| 100 |
1100 ... 2 |
| 101 |
3522652 ... 4 |
| 102 |
1036 ... 1 |
| 103 |
1084 ... 7 |
| 104 |
1108 ... 19 |
| 105 |
1 ... 432 |
| 106 |
12 ... 137 |
| 107 |
</tt></pre></blockquote> |
| 108 |
|
| 109 |
</p> |
| 110 |
|
| 111 |
<p>The table of exit status codes and frequencies is a new interesting |
| 112 |
aspect of the test. This test was run on a VMS system, so that we have |
| 113 |
a normal process exit 432 times, access violation 137 times, |
| 114 |
and reserved operand fault 19 times, etc. As the number of tries goes |
| 115 |
up (50 in this case) we would expect that the number of normal process |
| 116 |
exits to go down. |
| 117 |
</p> |
| 118 |
<p>If you define an environment variable (or vms logical name) |
| 119 |
called CRASHLOG then each subprocess will append to a file the |
| 120 |
arguments it was given. In that way you can recover what instance |
| 121 |
possibly caused a crash, but remember that without frequent disk fsync |
| 122 |
operations most Unix systems will leave a CRASHLOG that is out of |
| 123 |
date by a few minutes or more. |
| 124 |
</p> |
| 125 |
|
| 126 |
<p>Here is some output supplied by [email protected] on one of his machines. |
| 127 |
|
| 128 |
<blockquote><pre><tt> |
| 129 |
Processor : Intergraph Clipper C300 RISC processor |
| 130 |
16Mb memory + 4k I cache and 4K D cache |
| 131 |
|
| 132 |
Operating System: CLIX Version c.5.3.2 |
| 133 |
derived from AT&T SVR 3.1 with BSD enhancements. |
| 134 |
|
| 135 |
Crashme: (c) Copyright 1990, 1991 George J. Carrette |
| 136 |
Version: 1.7 25-SEP-1991 |
| 137 |
Subprocess run for 9000 seconds (0 02:30:00) |
| 138 |
Test complete, total real time: 9004 seconds (0 02:30:04) |
| 139 |
exit status ... number of cases |
| 140 |
136 ... 1 |
| 141 |
24576 ... 1 |
| 142 |
14 ... 1 |
| 143 |
138 ... 11 |
| 144 |
135 ... 27 |
| 145 |
140 ... 26 |
| 146 |
132 ... 430 |
| •147 |
139 ... 18 |
| 148 |
12800 ... 567 |
| 149 |
</tt></pre></blockquote> |
| 150 |
|
| 151 |
</p> |
| 152 |
<p>The status values here could be decoded by reading the |
| 153 |
documentation for the "wait" system procedure, and looking up the |
| 154 |
correct part of the value in the sys_errlist[] array. That is left as |
| 155 |
an exercise for the reader. |
| 156 |
</p> |
| 157 |
|
| 158 |
<hr/> |
| 159 |
|
| 160 |
<p>To compile, some systems may need #include <sys/types.h>. |
| 161 |
</p> |
| 162 |
|
| 163 |
<p>Also, note the conditionalized code in bad_malloc. If your system |
| 164 |
only gets the signal "segmentation violation" then you may need |
| 165 |
to consider conditionalizations along this line. |
| 166 |
</p> |
| 167 |
|
| 168 |
<p>However, on a machine with a segmented address space, that has |
| 169 |
"instructions" in one segment and "data" in another, it is highly |
| 170 |
unlikely that the code for setting up and invoking the "void |
| 171 |
(*badboy)()" will have any interesting effect. Nothing other than an |
| 172 |
easily handled SIGSEGV will result in the inner testing loop. |
| 173 |
</p> |
| 174 |
|
| 175 |
<p>Some PDP-11 systems would be examples of this situation (different |
| 176 |
I and D space). |
| 177 |
</p> |
| 178 |
|
| 179 |
<p>---MACHINE O/S SPECIFIC NOTES--- |
| 180 |
</p> |
| 181 |
|
| 182 |
<p>MACHINE:: DEC C (OPENVMS ALPHA AXP): |
| 183 |
|
| 184 |
|
| 185 |
<blockquote><pre><tt> |
| 186 |
$ CC/PREFIX=ALL/NOOPTIMIZE CRASHME |
| 187 |
$ LINK CRASHME |
| 188 |
</tt></pre></blockquote> |
| 189 |
|
| 190 |
</p> |
| 191 |
|
| 192 |
<p>New for version 2.2 code has been added to hackishly manipulate |
| 193 |
the Procedure Descriptor data format. It seems be executing random |
| 194 |
instructions like we would want. |
| 195 |
|
| 196 |
<blockquote><pre><tt> |
| 197 |
#if defined(__ALPHA) && defined(VMS) && !defined(NOCASTAWAY) |
| 198 |
</tt></pre></blockquote> |
| 199 |
|
| 200 |
</p> |
| 201 |
|
| 202 |
<p>Without this hack crashme on this platform has very little chance |
| 203 |
of causing anything other than a SIGBUS bus error. |
| 204 |
</p> |
| 205 |
|
| 206 |
<p>Perhaps a smart "learning" mode of random-data creation could |
| 207 |
achieve the same ends, maximizing some measurement of punishment. |
| 208 |
<a href="http://www.aaai.org/Conferences/National/1996/Tutorials/koza.html">Genetic programming</a> might be useful. |
| 209 |
</p> |
| 210 |
|
| 211 |
<p>Test I've tried: |
| 212 |
|
| 213 |
<blockquote><pre><tt> |
| 214 |
$crashme +1000.48 0 100 03:00:00 2 |
| 215 |
</tt></pre></blockquote> |
| 216 |
</p> |
| 217 |
|
| 218 |
<p>MACHINE:: Windows NT: |
| 219 |
</p> |
| 220 |
|
| 221 |
<p>The only files needed are crashme.c,makefile.wnt, and make.bat. cd |
| 222 |
into the directory containing the files and you can make two versions. |
| 223 |
crashme and crashmep (posix). |
| 224 |
|
| 225 |
<blockquote><pre><tt> |
| 226 |
>make |
| 227 |
</tt></pre></blockquote> |
| 228 |
</p> |
| 229 |
<p>In WIN32 subsystem the subprocess-all-at-once mode has not been |
| 230 |
implemented, but the sequential (-nsub) and timed modes have been |
| 231 |
implemented. |
| 232 |
</p> |
| 233 |
|
| 234 |
<p>In posix subsystem you must use the full name of the file in the |
| 235 |
command if you want to generate subprocesses. |
| 236 |
|
| 237 |
<blockquote><pre><tt> |
| 238 |
>crashmep.exe ..... |
| 239 |
</tt></pre></blockquote> |
| 240 |
|
| 241 |
On an 486DX2-66 machine the following caused a totally |
| 242 |
wedged up machine in the Windows NT final release. (Build 511). |
| 243 |
This was built in WIN32 mode with debugging on. |
| 244 |
|
| 245 |
<blockquote><pre><tt> |
| 246 |
>crashme +1000 666 50 12:00:00 3 |
| 247 |
</tt></pre></blockquote> |
| 248 |
|
| 249 |
</p> |
| 250 |
<p>In the posix subsystem the more verbose modes were not ever observed |
| 251 |
to go through more than 2 setjmp/longjmp cycles on a given random |
| 252 |
number seed. In the WIN32 subsystem there was a greater variety of |
| 253 |
fault conditions. |
| 254 |
</p> |
| 255 |
|
| 256 |
<p>The above crash took place after about 6 hours of running. Final |
| 257 |
subprocess arguments were +1000 24131 50, and we verified twice that |
| 258 |
invoking the following crashed the OS within seconds. |
| 259 |
|
| 260 |
<blockquote><pre><tt> |
| 261 |
>crashme +1000 24131 50 |
| 262 |
</tt></pre></blockquote> |
| 263 |
|
| 264 |
</p> |
| 265 |
|
| 266 |
<p>I have always been concerned that the more complex the unprotected |
| 267 |
data in the user address space the more likely it is for a program |
| 268 |
being developed to generate inscrutable errors that an "application |
| 269 |
developer" level of person will be unable to understand. And worse, |
| 270 |
will end up spinning wheels for large amounts of time, thereby |
| 271 |
delaying projects and risking deadline failures, and even worse, |
| •272 |
forcing management to bring in super-experienced (and limited |
| 273 |
availability) people into a project in order to get it going again. |
| 274 |
</p> |
| 275 |
|
| 276 |
<p>The WINDOWS NT client-server model is one way around this problem. |
| 277 |
Having a subsystem in a different address space is one way to protect |
| 278 |
complex data manipulated through an API. However, as page 127 of |
| 279 |
"Inside Windows NT" there are some optimizations that make an unspoken |
| 280 |
trade-off between the robustness afforded by a protected separate |
| 281 |
address space and efficiency of implementation on an API. |
| 282 |
</p> |
| 283 |
<p>Robustness and 'scrutability of failure situations' vs efficiency. |
| 284 |
</p> |
| 285 |
|
| 286 |
<p>MACHINE:: OS/2 |
| 287 |
</p> |
| 288 |
|
| 289 |
<p>It has been reported that this runs when compiled gcc crashme.c -o |
| 290 |
crashme.exe In order to disable the dialog boxes reporting abnormal |
| 291 |
process termination, add this to CONFIG.SYS: AUTOFAIL=YES. Or the |
| 292 |
following code to main: |
| 293 |
|
| 294 |
<blockquote><pre><tt> |
| 295 |
DosError(FERR_DISABLEHARDERR | FERR_DISABLEEXCEPTION); |
| 296 |
</tt></pre></blockquote> |
| 297 |
|
| 298 |
</p> |
| 299 |
<p>Another person says that Emx is the only c compiler under OS/2 that |
| 300 |
supports fork. |
| 301 |
</p> |
| 302 |
<hr/> |
| 303 |
|
| 304 |
<p> |
| 305 |
Survey of Procedure Descriptor Usage. The emphasis here is on |
| 306 |
currently shipping products. The program pddet.c included |
| 307 |
with the distribution can be used to determine some of this |
| 308 |
information. Note that in some environments, e.g. Microsoft C++ 4.0 |
| 309 |
the results of PDDET will be different depending on the compilation |
| 310 |
modes chosen: debug verses release. |
| 311 |
|
| 312 |
<blockquote><pre><tt> |
| 313 |
Architecture |D| Desc | Env | Reg | Apos | Atyp | Rpos | Rtyp | |
| 314 |
------------------------------------------------------------------ |
| 315 |
VAX |2| No | No | Yes | No | No | No | No | |
| 316 |
ALPHA, OPENVMS |3| Yes | Yes | Yes | Yes | Opt | Yes | Opt | |
| 317 |
ALPHA, WNT | | No | | | | | | | |
| 318 |
ALPHA, OSF/1 | | No | | | | | | | |
| 319 |
RS/6000, AIX |2| Yes | Yes | No | No | No | No | No | |
| 320 |
PowerPC, |2| Yes | Yes | No | No | No | No | No | |
| 321 |
MIPS, Unix | | | | | | | | | |
| 322 |
MIPS, WNT | | | | | | | | | |
| 323 |
Intel, WNT | | | | | | | | | |
| 324 |
Sparc, SUNOS | | No | | | | | | | |
| 325 |
PA-RISC, HPUX |2| Yes | | | | | | | |
| 326 |
------------------------------------------------------------------ |
| 327 |
|
| 328 |
Legend: |
| 329 |
|
| 330 |
D ... level of detailed information I have available |
| 331 |
1 = Verbal description or suspect from pddet.c |
| 332 |
2 = exact structure details including code for CRASHME.C |
| 333 |
or obvious what it is from pddet.c |
| 334 |
3 = crashme uses manufacturers include files for descriptors. |
| 335 |
Desc ... Uses descriptors |
| 336 |
Env ... has pointer to non-static environment |
| 337 |
Reg ... describes registers used |
| 338 |
Apos ... describes argument positions (stack, registers) or number. |
| 339 |
Atyp ... describes argument types |
| 340 |
Rpos ... describes return value position. |
| 341 |
Rtyp ... describes return value types |
| 342 |
|
| 343 |
Layout of Descriptors. Sizes in bytes. |
| 344 |
|
| 345 |
ALPHA OPENVMS: |
| 346 |
|
| 347 |
[FLAGS&KIND] 2 |
| 348 |
[REG-SAVE] 2 |
| 349 |
[REG-FOR-RETPC] 1 |
| 350 |
[REG-FOR-RETVAL] 1 |
| 351 |
[SIGNATURE-OFFSET] 2 |
| 352 |
[START-PC] 8 |
| 353 |
[Other stuff ...] from 8 to 32 bytes worth. |
| 354 |
|
| 355 |
AIX |
| 356 |
|
| 357 |
actually points to a 3 word struct with: |
| 358 |
- the actual function address |
| 359 |
- Table Of Contents (r2) register value |
| 360 |
- Environment (r11) pointer (for nested functions) |
| 361 |
|
| 362 |
POWERPC |
| 363 |
|
| 364 |
[PROGRAM-COUNTER] |
| 365 |
[TABLE-OF-CONTENTS] |
| 366 |
[EXCEPTION-INFO] |
| 367 |
|
| 368 |
</tt></pre></blockquote> |
| 369 |
|
| 370 |
</p> |
| 371 |
|
| 372 |
<p> |
| 373 |
[Editorial comment taken from comp.arch:] Not to sound picky about |
| 374 |
this, but this is not really part of the POWER/PowerPC architecture. |
| 375 |
There is no special support for this in the hardware, it is just the |
| 376 |
scheme the software designers came up with in order to support shared |
| 377 |
libraries. Other schemes would be possible. [GJC comment] Pretty |
| 378 |
much true for every architecture. |
| 379 |
|
| 380 |
</p> |
| 381 |
|
| 382 |
<p>PA-RISC HPUX. |
| 383 |
</p> |
| 384 |
|
| 385 |
<p>The pddet.c program was used, and suggested descriptors of 8 |
| 386 |
bytes long. The -examine 8 argument showed what appeared to |
| 387 |
be a 4-byte starting PC followed by a table of contents. |
| 388 |
Note: If somebody knows what /usr/include/sys/*.h file to use |
| 389 |
for this, please let me know. |
| 390 |
</p> |
| 391 |
|
| 392 |
|
| 393 |
<p>Notes for release 2.6 of Crashme. 13-JUL-2008 GJC. |
| 394 |
</p> |
| 395 |
|
| 396 |
<p>CRASHPRNG is a new environment variable letting you change the |
| 397 |
pseudorandom number generator used. |
| 398 |
|
| 399 |
<table border="1"> |
| 400 |
<tr><th>CRASHPRNG</th><th>description</th></tr> |
| 401 |
<tr><td>RAND</td><td>C runtime library rand</td></tr> |
| 402 |
<tr><td>MT (default)</td> |
| 403 |
<td>Mersenne twister coded by Takuji Nishimura and Makoto Matsumoto.</td></tr> |
| 404 |
<tr><td>VNSQ</td> |
| 405 |
<td>A variation of the middle square method</td></tr> |
| 406 |
</table> |
| 407 |
|
| 408 |
</p> |
| 409 |
|
| 410 |
<!-- Notes: |
| 411 |
Any PRNG collection designed for monte carlo methods written in ANSI C would |
| 412 |
be useful here. This one looks nice: |
| 413 |
http://statmath.wu-wien.ac.at/prng/doc/prng.html |
| 414 |
Also of course http://www.stat.fsu.edu/pub/diehard/ |
| 415 |
--> |
| 416 |
|
| 417 |
</body> |
| 418 |
</html> |
| 419 |
|