diff options
author | Leah Neukirchen <leah@vuxu.org> | 2019-01-11 15:52:56 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2019-01-11 15:52:56 +0100 |
commit | 210da56f6ff711ba6b92d0b83f0c2ecfc824cff0 (patch) | |
tree | 67b08d1b0b5ae61cff605118ddefd33451264944 | |
parent | 7f7d49564d86851ef74e48fce23bb5f54f22b392 (diff) | |
download | fail-210da56f6ff711ba6b92d0b83f0c2ecfc824cff0.tar.gz fail-210da56f6ff711ba6b92d0b83f0c2ecfc824cff0.tar.xz fail-210da56f6ff711ba6b92d0b83f0c2ecfc824cff0.zip |
new fail: recurse_alloca (to test -fstack-clash-protection)
-rw-r--r-- | README | 12 | ||||
-rw-r--r-- | fail.1 | 14 | ||||
-rw-r--r-- | fail.c | 17 |
3 files changed, 33 insertions, 10 deletions
diff --git a/README b/README index e057c9f..bf5a812 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ NAME fail – crash in various possible ways SYNOPSIS - fail [-123DOabcdikrst] + fail [-123DORabcdikrst] DESCRIPTION fail crashes in various possible ways to help you debug how other @@ -29,6 +29,9 @@ DESCRIPTION Warning: this may lock up your machine and/or result in killing other processes, too. Use with caution. + -R Trigger an infinite recursion that uses alloca(3) heavily (to + test GCC's -fstack-clash-protection). + -a Call abort(3). -b Trigger SIGBUS by accessing mmap(2) memory beyond the end of a @@ -42,7 +45,8 @@ DESCRIPTION -k Raise SIGKILL. - -r Trigger an infinite recursion. + -r Trigger an infinite recursion that uses less than a page of stack + per level. -s Trigger a segmentation fault by writing to a null pointer. @@ -63,6 +67,6 @@ LICENSE To the extent possible under law, the creator of this work has waived all copyright and related or neighboring rights to this work. - http://creativecommons.org/publicdomain/zero/1.0/ + http://creativecommons.org/publicdomain/zero/1.0/ -Void Linux February 8, 2017 Void Linux +Void Linux January 11, 2019 Void Linux diff --git a/fail.1 b/fail.1 index c1ff07e..8026683 100644 --- a/fail.1 +++ b/fail.1 @@ -1,4 +1,4 @@ -.Dd February 08, 2017 +.Dd January 11, 2019 .Dt FAIL 1 .Os .Sh NAME @@ -6,7 +6,7 @@ .Nd crash in various possible ways .Sh SYNOPSIS .Nm -.Op Fl 123DOabcdikrst +.Op Fl 123DORabcdikrst .Sh DESCRIPTION .Nm crashes in various possible ways to @@ -42,6 +42,14 @@ A dot is printed after each 16MB allocation. this may lock up your machine and/or result in killing other processes, too. Use with caution. +.It Fl R +Trigger an infinite recursion that uses +.Xr alloca 3 +heavily +.Po +to test GCC's +.Fl fstack-clash-protection +.Pc . .It Fl a Call .Xr abort 3 . @@ -60,7 +68,7 @@ Execute an illegal instruction. .It Fl k Raise SIGKILL. .It Fl r -Trigger an infinite recursion. +Trigger an infinite recursion that uses less than a page of stack per level. .It Fl s Trigger a segmentation fault by writing to a null pointer. .It Fl t diff --git a/fail.c b/fail.c index b95b1b6..5d1b80b 100644 --- a/fail.c +++ b/fail.c @@ -9,6 +9,7 @@ #include <sys/stat.h> #include <sys/types.h> +#include <alloca.h> #include <fcntl.h> #include <signal.h> #include <stdio.h> @@ -73,13 +74,22 @@ oom() void recurse(char *n) { - char m[1024]; + char m[512]; recurse(m); if (n) m[0] = n[0] = 42; } void +recurse_alloca(char *n) +{ + char *m = alloca(1024*1024); + recurse_alloca(m); + if (n) + m[0] = n[0] = 42; +} + +void abortme() { abort(); @@ -148,13 +158,14 @@ main(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "123DOabcdikrst")) != -1) { + while ((c = getopt(argc, argv, "123DORabcdikrst")) != -1) { switch (c) { case '1': exit(-1); break; case '2': exit(2); break; case '3': exit(111); break; case 'D': uninterruptible(); break; case 'O': oom(); break; + case 'R': recurse_alloca(0); break; case 'a': abortme(); break; case 'b': mmap_sigbus(); break; case 'c': violate_seccomp(); break; @@ -167,6 +178,6 @@ main(int argc, char *argv[]) } } - write(2, "Usage: fail [-123Oabcdikrst]\n", 29); + write(2, "Usage: fail [-123ORabcdikrst]\n", 30); exit(1); } |