diff options
author | Pavel Machek <pavel@ucw.cz> | 2000-02-01 16:12:33 +0000 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2000-02-01 16:12:33 +0000 |
commit | 245a6ac0e71d7ecdbb776b12b735de58cf5a055b (patch) | |
tree | 762d77535e043dd06f099b9713fd4ccecbfa9786 /test | |
parent | 5597f898dfb01586bd1c659c415ffd798a8517db (diff) | |
download | strace-245a6ac0e71d7ecdbb776b12b735de58cf5a055b.tar.gz strace-245a6ac0e71d7ecdbb776b12b735de58cf5a055b.tar.bz2 strace-245a6ac0e71d7ecdbb776b12b735de58cf5a055b.tar.xz |
Automatically probe for sys/poll.h
Include example of nasty program where strace (by design) gives
incorrect output.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/skodic.c | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile index 36670cb..ddaa404 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,7 +2,7 @@ # $Id$ # -all: fork sig +all: fork sig skodic clean distclean: rm -f fork sig *.o core diff --git a/test/skodic.c b/test/skodic.c new file mode 100644 index 0000000..4e65d5d --- /dev/null +++ b/test/skodic.c @@ -0,0 +1,30 @@ +/* This demonstrates races: kernel may actually open other file then + * you read at strace output. Create /tmp/delme with 10K of zeros and + * 666 mode, then run this under strace. If you see open successfull + * open of /etc/shadow, you know you've seen a race. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +void +main(void) +{ + char *c = 0x94000000; + open( "/tmp/delme", O_RDWR ); + mmap( c, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, 3, 0 ); + *c = 0; + if (fork()) { + while(1) { + strcpy( c, "/etc/passwd" ); + strcpy( c, "/etc/shadow" ); + } + } else + while (1) + open( c, 0 ); +} |