Index: user/pho/stress2/misc/fifo2.sh =================================================================== --- user/pho/stress2/misc/fifo2.sh (revision 338531) +++ user/pho/stress2/misc/fifo2.sh (revision 338532) @@ -1,209 +1,208 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Page fault seen # http://people.freebsd.org/~pho/stress/log/kostik654.txt # Fixed by r259521. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > fifo2.c rm -f /tmp/fifo2 mycc -o fifo2 -Wall -Wextra -O2 -g fifo2.c -lpthread || exit 1 rm -f fifo2.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint mkfifo $mntpoint/f chmod 777 $mntpoint/f sleeptime=12 st=`date '+%s'` while [ $((`date '+%s'` - st)) -lt $((10 * sleeptime)) ]; do (cd $mntpoint; /tmp/fifo2) & start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt $sleeptime ]; do pgrep -q fifo2 || break sleep .5 done while pkill -9 fifo2; do :; done wait done for i in `jot 10`; do mount | grep -q md${mdstart}$part && \ umount $mntpoint > /dev/null 2>&1 && mdconfig -d -u $mdstart && break sleep 10 done s=0 mount | grep -q md${mdstart}$part && { echo "umount $mntpoint failed"; s=1; } rm -f /tmp/fifo2 exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } static unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } static void * calls(void *arg __unused) { unsigned long arg1, arg2, arg3, arg4, arg5, arg6, arg7; int i, num; for (i = 0;; i++) { arg1 = (unsigned long)(void *)"f"; arg2 = makearg(); arg3 = makearg(); arg4 = makearg(); arg5 = makearg(); arg6 = makearg(); arg7 = makearg(); #if 0 fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", i, SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); usleep(100000); #endif alarm(1); syscall(SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); num = 0; } return (0); } int main(void) { struct passwd *pw; struct rlimit limit; pthread_t cp[50]; time_t start; int e, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); limit.rlim_cur = limit.rlim_max = 1000; if (setrlimit(RLIMIT_NPTS, &limit) < 0) err(1, "setrlimit"); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); start = time(NULL); while ((time(NULL) - start) < 120) { if (fork() == 0) { - arc4random_stir(); for (j = 0; j < 1; j++) if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) errc(1, e,"pthread_create"); for (j = 0; j < 1; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } Index: user/pho/stress2/misc/ftruncate.sh =================================================================== --- user/pho/stress2/misc/ftruncate.sh (revision 338531) +++ user/pho/stress2/misc/ftruncate.sh (revision 338532) @@ -1,195 +1,194 @@ #!/bin/sh # # Copyright (c) 2016 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # ftruncate(2) fuzz. # "panic: softdep_deallocate_dependencies: dangling deps" seen in # 10.3-STABLE: # https://people.freebsd.org/~pho/stress/log/ftruncate.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=$RUNDIR odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > ftruncate.c rm -f /tmp/ftruncate mycc -o ftruncate -Wall -Wextra -O2 -g ftruncate.c -lpthread || exit 1 rm -f ftruncate.c rm -rf $dir mkdir -p $dir chmod 777 $dir cd $dir jot 500 | xargs touch jot 500 | xargs chmod 666 cd $odir (cd /tmp; /tmp/ftruncate $dir) e=$? rm -rf $dir rm -f /tmp/ftruncate exit $e EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) #define RUNTIME 180 #define THREADS 2 static int fd[900]; static u_int32_t r[N]; static char *args[2]; static unsigned long makearg(void) { unsigned long val; val = arc4random(); #if defined(__LP64__) val = (val << 32) | arc4random(); val = val & 0x00007fffffffffffUL; #endif return(val); } static void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions, i, n; ftsoptions = FTS_PHYSICAL; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = n = 0; while ((p = fts_read(fts)) != NULL) { if (fd[i] > 0) close(fd[i]); if ((fd[i] = open(p->fts_path, O_RDWR)) == -1) if ((fd[i] = open(p->fts_path, O_WRONLY)) == -1) continue; i++; i = i % nitems(fd); } if (fts_close(fts) == -1) err(1, "fts_close()"); sleep(1); } return(0); } static void * calls(void *arg __unused) { off_t offset; time_t start; int fd2; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { fd2 = makearg() % nitems(fd) + 3; offset = makearg(); if (ftruncate(fd2, offset) == 0) { if (lseek(fd2, offset - 1, SEEK_SET) != -1) write(fd2, "x", 1); } } return (0); } int main(int argc, char **argv) { struct passwd *pw; pthread_t rp, cp[THREADS]; int e, i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } args[0] = argv[1]; args[1] = 0; if ((pw = getpwnam("nobody")) == NULL) err(1, "failed to resolve nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); - arc4random_stir(); if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); usleep(1000); for (i = 0; i < THREADS; i++) if ((e = pthread_create(&cp[i], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < THREADS; i++) pthread_join(cp[i], NULL); return (0); } Index: user/pho/stress2/misc/ftruncate2.sh =================================================================== --- user/pho/stress2/misc/ftruncate2.sh (revision 338531) +++ user/pho/stress2/misc/ftruncate2.sh (revision 338532) @@ -1,212 +1,211 @@ #!/bin/sh # # Copyright (c) 2016 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # A fuzz test triggered a failed block allocation unwinding problem. # "panic: ffs_blkfree_cg: freeing free block" seen: # https://people.freebsd.org/~pho/stress/log/kostik923.txt # Fixed by r304232. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > ftruncate2.c rm -f /tmp/ftruncate2 mycc -o ftruncate2 -Wall -Wextra -O2 -g ftruncate2.c -lpthread || exit 1 rm -f ftruncate2.c echo "Expect: \"/mnt: write failed, filesystem is full\"" mount | grep $mntpoint | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null # Non SU panics mount /dev/md${mdstart}$part $mntpoint dir=$mntpoint chmod 777 $dir cd $dir jot 500 | xargs touch jot 500 | xargs chmod 666 cd $odir (cd /tmp; /tmp/ftruncate2 $dir) e=$? rm -rf $dir/* while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/ftruncate2 exit $e EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) #define RUNTIME 180 #define THREADS 2 static int fd[900]; static u_int32_t r[N]; static char *args[2]; static unsigned long makearg(void) { unsigned long val; val = arc4random(); #if defined(__LP64__) val = (val << 32) | arc4random(); val = val & 0x00007fffffffffffUL; #endif return(val); } static void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions, i, n; ftsoptions = FTS_PHYSICAL; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = n = 0; while ((p = fts_read(fts)) != NULL) { if (fd[i] > 0) close(fd[i]); if ((fd[i] = open(p->fts_path, O_RDWR)) == -1) if ((fd[i] = open(p->fts_path, O_WRONLY)) == -1) continue; if (ftruncate(fd[i], 0) != 0) err(1, "ftruncate"); i++; i = i % nitems(fd); } if (fts_close(fts) == -1) err(1, "fts_close()"); sleep(1); } return(0); } static void * calls(void *arg __unused) { off_t offset; time_t start; int fd2; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { fd2 = makearg() % nitems(fd) + 3; offset = makearg(); if (lseek(fd2, offset - 1, SEEK_SET) != -1) { if (write(fd2, "x", 1) != 1) if (errno != EBADF && errno != ENOSPC && errno != E2BIG && errno != ESTALE && errno != EFBIG) warn("write"); } else if (errno != EBADF) warn("lseek"); if (fsync(fd2) == -1) if (errno != EBADF) warn("x"); } return (0); } int main(int argc, char **argv) { struct passwd *pw; pthread_t rp, cp[THREADS]; int e, i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } args[0] = argv[1]; args[1] = 0; if ((pw = getpwnam("nobody")) == NULL) err(1, "failed to resolve nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); - arc4random_stir(); if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); usleep(1000); for (i = 0; i < THREADS; i++) if ((e = pthread_create(&cp[i], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < THREADS; i++) pthread_join(cp[i], NULL); return (0); } Index: user/pho/stress2/misc/mlockall3.sh =================================================================== --- user/pho/stress2/misc/mlockall3.sh (revision 338531) +++ user/pho/stress2/misc/mlockall3.sh (revision 338532) @@ -1,170 +1,169 @@ #!/bin/sh # # Copyright (c) 2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # mlockall(2) test scenario. # "panic: vm_page_unwire: page xxx's wire count is zero" seen. # http://people.freebsd.org/~pho/stress/log/mlockall.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mlockall3.c mycc -o mlockall3 -Wall -Wextra mlockall3.c -lpthread || exit 1 rm -f mlockall3.c cd $odir /tmp/mlockall3 killall mlockall3 > /dev/null 2>&1 rm -f /tmp/mlockall3 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * calls(void *arg __unused) { int i; unsigned long arg1, arg2, arg3; usleep(1000); for (i = 0; i < 500; i++) { arg1 = makearg(); arg2 = makearg(); arg3 = makearg(); alarm(1); syscall(SYS_mlockall, arg1, arg2, arg3); } return (0); } int main(void) { struct passwd *pw; pid_t pid; pthread_t cp[50]; int e, i, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); alarm(180); for (i = 0; i < 8000; i++) { if ((pid = fork()) == 0) { - arc4random_stir(); for (j = 0; j < N; j++) r[j] = arc4random(); for (j = 0; j < 50; j++) if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (j = 0; j < 50; j++) pthread_join(cp[j], NULL); _exit(0); } if (pid == -1) err(1, "fork()"); wait(NULL); } return (0); } Index: user/pho/stress2/misc/msync.sh =================================================================== --- user/pho/stress2/misc/msync.sh (revision 338531) +++ user/pho/stress2/misc/msync.sh (revision 338532) @@ -1,204 +1,203 @@ #!/bin/sh # # Copyright (c) 2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # msync(2) / mlockall(2) test scenario. # "panic: vm_fault_copy_wired: page missing" seen. # http://people.freebsd.org/~pho/stress/log/msync.txt # Fixed in r253189. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/msync.c mycc -o msync -Wall -Wextra msync.c -lpthread || exit 1 rm -f msync.c cd $odir /tmp/msync & sleep 180 while pkill -9 msync; do :; done wait rm -f /tmp/msync exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int syscallno = SYS_msync; #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * calls(void *arg __unused) { int i, num; unsigned long arg1, arg2, arg3; usleep(1000); num = syscallno; for (i = 0; i < 500; i++) { arg1 = makearg(); arg2 = makearg(); #if 0 arg3 = makearg(); arg3 = arg3 & ~MS_INVALIDATE; /* No problem seen */ #else arg3 = MS_INVALIDATE; /* panic */ #endif #if 0 fprintf(stderr, "%2d : syscall(%3d, 0x%lx, 0x%lx, 0x%lx)\n", i, num, arg1, arg2, arg3); usleep(50000); #endif alarm(1); syscall(num, arg1, arg2, arg3); num = 0; } return (0); } void wd(void) { int i; if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) err(1, "mlockall failed"); for (i = 0; i < 800; i++) { if (fork() == 0) { usleep(20000); _exit(0); } wait(NULL); usleep(100000); } _exit(0); } int main(void) { struct passwd *pw; pthread_t cp[50]; int e, i, j; if (fork() == 0) wd(); if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); alarm(180); for (i = 0; i < 8000; i++) { if (fork() == 0) { - arc4random_stir(); for (j = 0; j < N; j++) r[j] = arc4random(); for (j = 0; j < 50; j++) if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (j = 0; j < 50; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } Index: user/pho/stress2/misc/suj5.sh =================================================================== --- user/pho/stress2/misc/suj5.sh (revision 338531) +++ user/pho/stress2/misc/suj5.sh (revision 338532) @@ -1,185 +1,184 @@ #!/bin/sh # # Copyright (c) 2010 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD: projects/stress2/misc/suj.sh 210724 2010-08-01 10:33:03Z pho $ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Deadlock seen . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj5.c mycc -o suj5 -Wall -O2 suj5.c rm -f suj5.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/suj5" > /dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/suj5 exit EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 10 static int random_int(int mi, int ma) { return (arc4random() % (ma - mi + 1) + mi); } static int64_t df(void) { char path[MAXPATHLEN+1]; struct statfs buf; if (getcwd(path, sizeof(path)) == NULL) err(1, "getcwd()"); if (statfs(path, &buf) < 0) err(1, "statfs(%s)", path); printf("Free space on %s: %jd Mb\n", path, buf.f_bavail * buf.f_bsize / 1024 / 1024); return (buf.f_bavail * buf.f_bsize); } static void test(int size) { int buf[1024], index, to; #ifdef TEST int i; #endif int fd; char file[128]; sprintf(file,"p%05d", getpid()); if ((fd = creat(file, 0660)) == -1) err(1, "creat(%s)", file); to = sizeof(buf); index = 0; while (index < size) { if (index + to > size) to = size - index; #ifdef TEST for (i = 0; i < to; i++) buf[i] = index + i; #endif index += to; if (write(fd, buf, to) != to) err(1, "write(%s), %s:%d", file, __FILE__, __LINE__); } if (close(fd) == -1) err(1, "close(%s), %s:%d", file, __FILE__, __LINE__); if ((fd = open(file, O_RDONLY)) == -1) err(1, "open(%s), %s:%d", file, __FILE__, __LINE__); index = 0; while (index < size) { if (index + to > size) to = size - index; if (read(fd, buf, to) != to) err(1, "rw read. %s.%d", __FILE__, __LINE__); #ifdef TEST for (i = 0; i < to; i++) { if (buf[i] != index + i) { fprintf(stderr, "%s, pid %d: expected %d @ %d, got %d\n", getprogname(), getpid(), index+i, index+i, buf[i]); exit(EXIT_FAILURE); } } #endif index += to; } if (close(fd) == -1) err(1, "close(%s), %s:%d", file, __FILE__, __LINE__); if (unlink(file) == -1) err(1, "unlink(%s), %s:%d", file, __FILE__, __LINE__); exit(0); } int main() { int i, j, pct; int size; /* in k */ int64_t bl; bl = df(); if (bl > (int64_t)INT_MAX * PARALLEL) bl = (int64_t)INT_MAX * PARALLEL; size = bl / PARALLEL / 1024; pct = random_int(1, 50); size = size / 100 * pct + 1; if (random_int(1, 100) <= 50) size = 34 * 1024; /* Known good deadlock value */ printf("Max file size: %d Mb\n", size / 1024); for (i = 0; i < 100; i++) { for (j = 0; j < PARALLEL; j++) { if (fork() == 0) { - arc4random_stir(); test(random_int(1, size) * 1024); } } for (j = 0; j < PARALLEL; j++) wait(NULL); } return (0); } Index: user/pho/stress2/misc/suj6.sh =================================================================== --- user/pho/stress2/misc/suj6.sh (revision 338531) +++ user/pho/stress2/misc/suj6.sh (revision 338532) @@ -1,188 +1,187 @@ #!/bin/sh # # Copyright (c) 2010 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD: projects/stress2/misc/suj.sh 210724 2010-08-01 10:33:03Z pho $ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Variation of suj5.sh # "panic: indir_trunc: Index out of range -2 parent -2061 lbn -2060" seen . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj6.c mycc -o suj6 -Wall -O2 suj6.c rm -f suj6.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/suj6" > /dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/suj6 exit EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 10 static int random_int(int mi, int ma) { return (arc4random() % (ma - mi + 1) + mi); } static int64_t df(void) { char path[MAXPATHLEN+1]; struct statfs buf; if (getcwd(path, sizeof(path)) == NULL) err(1, "getcwd()"); if (statfs(path, &buf) < 0) err(1, "statfs(%s)", path); printf("Free space on %s: %jd Mb\n", path, buf.f_bavail * buf.f_bsize / 1024 / 1024); return (buf.f_bavail * buf.f_bsize); } static void test(int size) { int buf[1024], index, to; #ifdef TEST int i; #endif int fd; char file[128]; sprintf(file,"p%05d", getpid()); if ((fd = creat(file, 0660)) == -1) err(1, "creat(%s)", file); to = sizeof(buf); index = 0; while (index < size) { if (index + to > size) to = size - index; #ifdef TEST for (i = 0; i < to; i++) buf[i] = index + i; #endif index += to; if (write(fd, buf, to) != to) err(1, "write(%s), %s:%d", file, __FILE__, __LINE__); } if (close(fd) == -1) err(1, "close(%s), %s:%d", file, __FILE__, __LINE__); #if 0 if ((fd = open(file, O_RDONLY)) == -1) err(1, "open(%s), %s:%d", file, __FILE__, __LINE__); index = 0; while (index < size) { if (index + to > size) to = size - index; if (read(fd, buf, to) != to) err(1, "rw read. %s.%d", __FILE__, __LINE__); #ifdef TEST for (i = 0; i < to; i++) { if (buf[i] != index + i) { fprintf(stderr, "%s, pid %d: expected %d @ %d, got %d\n", getprogname(), getpid(), index+i, index+i, buf[i]); exit(EXIT_FAILURE); } } #endif index += to; } if (close(fd) == -1) err(1, "close(%s), %s:%d", file, __FILE__, __LINE__); #endif if (unlink(file) == -1) err(1, "unlink(%s), %s:%d", file, __FILE__, __LINE__); exit(0); } int main() { int i, j, pct; int size; /* in k */ int64_t bl; bl = df(); if (bl > (int64_t)INT_MAX * PARALLEL) bl = (int64_t)INT_MAX * PARALLEL; size = bl / PARALLEL / 1024; pct = random_int(1, 50); size = size / 100 * pct + 1; if (random_int(1, 100) <= 50) size = 34 * 1024; /* Known good deadlock value */ printf("Max file size: %d Mb\n", size / 1024); for (i = 0; i < 100; i++) { for (j = 0; j < PARALLEL; j++) { if (fork() == 0) { - arc4random_stir(); test(random_int(1, size) * 1024); } } for (j = 0; j < PARALLEL; j++) wait(NULL); } return (0); } Index: user/pho/stress2/misc/tmpfs16.sh =================================================================== --- user/pho/stress2/misc/tmpfs16.sh (revision 338531) +++ user/pho/stress2/misc/tmpfs16.sh (revision 338532) @@ -1,206 +1,205 @@ #!/bin/sh # # Copyright (c) 2016 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # A fuzz test using random file descriptors with random seeks. # "panic: Assertion (cookie & TMPFS_DIRCOOKIE_MASK) == cookie failed": # https://people.freebsd.org/~pho/stress/log/kostik922.txt # Fixed by r303916. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "on $mntpoint " && umount -f $mntpoint mount -o size=1g -t tmpfs tmpfs $mntpoint RUNDIR=$mntpoint/stressX dir=$RUNDIR odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > tmpfs16.c rm -f /tmp/tmpfs16 mycc -o tmpfs16 -Wall -Wextra -O2 -g tmpfs16.c -lpthread || exit 1 rm -f tmpfs16.c rm -rf $dir mkdir -p $dir chmod 777 $dir cd $dir jot 500 | xargs touch jot 500 | xargs chmod 666 cd $odir (cd /tmp; /tmp/tmpfs16 $dir) e=$? rm -rf $dir umount $mntpoint rm -f /tmp/tmpfs16 exit $e EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) #define RUNTIME 180 #define THREADS 2 static int fd[900]; static u_int32_t r[N]; static char *args[2]; static unsigned long makearg(void) { unsigned long val; val = arc4random(); #if defined(__LP64__) val = (val << 31) | arc4random(); val = val & 0x00007fffffffffffUL; #endif return(val); } static void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions, i, n; ftsoptions = FTS_PHYSICAL; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = n = 0; while ((p = fts_read(fts)) != NULL) { if (fd[i] > 0) close(fd[i]); if ((fd[i] = open(p->fts_path, O_RDWR)) == -1) if ((fd[i] = open(p->fts_path, O_WRONLY)) == -1) continue; if (ftruncate(fd[i], 0) != 0) err(1, "ftruncate"); i++; i = i % nitems(fd); } if (fts_close(fts) == -1) err(1, "fts_close()"); sleep(1); } return(0); } static void * calls(void *arg __unused) { off_t offset; time_t start; int fd2; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { fd2 = makearg() % nitems(fd) + 3; offset = makearg(); if (lseek(fd2, offset - 1, SEEK_SET) != -1) { if (write(fd2, "x", 1) != 1) if (errno != EBADF && errno != ENOSPC) warn("write"); } else if (errno != EBADF) warn("lseek"); if (fsync(fd2) == -1) if (errno != EBADF) warn("x"); } return (0); } int main(int argc, char **argv) { struct passwd *pw; pthread_t rp, cp[THREADS]; int e, i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } args[0] = argv[1]; args[1] = 0; if ((pw = getpwnam("nobody")) == NULL) err(1, "failed to resolve nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); - arc4random_stir(); if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); usleep(1000); for (i = 0; i < THREADS; i++) if ((e = pthread_create(&cp[i], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < THREADS; i++) pthread_join(cp[i], NULL); return (0); }