diff options
| author | jvoisin | 2023-08-20 18:25:12 +0200 |
|---|---|---|
| committer | jvoisin | 2023-08-20 20:51:19 +0200 |
| commit | 70bbb621b5bad33b03053264abc6deb0c6c5525e (patch) | |
| tree | cf8dd99490b5be90fef7ebb98323e19f561bb57a | |
| parent | e182dd0138d8040c44481a48277cab4098ccca0a (diff) | |
Refresh a bit the README
| -rw-r--r-- | README | 110 | ||||
| -rw-r--r-- | README.md | 115 |
2 files changed, 115 insertions, 110 deletions
| @@ -1,110 +0,0 @@ | |||
| 1 | What is it? | ||
| 2 | =========== | ||
| 3 | |||
| 4 | This is a standalone implementation of fortify source[0]. It provides | ||
| 5 | compile time buffer checks. It is libc-agnostic and simply overlays the | ||
| 6 | system headers by using the #include_next extension found in GCC. It was | ||
| 7 | initially intended to be used on musl[1] based Linux distributions[2]. | ||
| 8 | |||
| 9 | |||
| 10 | Features | ||
| 11 | ======== | ||
| 12 | |||
| 13 | - It is portable, works on *BSD, Linux, Solaris and possibly others. | ||
| 14 | - It will only trap non-conformant programs. This means that fortify | ||
| 15 | level 2 is treated in the same way as level 1. | ||
| 16 | - Avoids making function calls when undefined behaviour has already been | ||
| 17 | invoked. This is handled by using __builtin_trap(). | ||
| 18 | - Support for out-of-bounds read interfaces, such as send(), write(), | ||
| 19 | fwrite() etc. | ||
| 20 | - No ABI is enforced. All of the fortify check functions are inlined | ||
| 21 | into the resulting binary. | ||
| 22 | |||
| 23 | |||
| 24 | Sample usage | ||
| 25 | ============ | ||
| 26 | |||
| 27 | If you want to quickly test it, you can try something like the following: | ||
| 28 | |||
| 29 | cat > fgets.c <<EOF | ||
| 30 | #include <stdio.h> | ||
| 31 | int | ||
| 32 | main(void) | ||
| 33 | { | ||
| 34 | char buf[BUFSIZ]; | ||
| 35 | fgets(buf, sizeof(buf) + 1, stdin); | ||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | EOF | ||
| 39 | cc -I<path-to-fortify-include-dir> -D_FORTIFY_SOURCE=1 -O1 fgets.c | ||
| 40 | ./a.out | ||
| 41 | |||
| 42 | At this point, the program will safely crash. | ||
| 43 | |||
| 44 | |||
| 45 | Supported interfaces | ||
| 46 | ==================== | ||
| 47 | |||
| 48 | FD_CLR | ||
| 49 | FD_SET | ||
| 50 | bcopy | ||
| 51 | bzero | ||
| 52 | confstr | ||
| 53 | fgets | ||
| 54 | fgetws | ||
| 55 | fread | ||
| 56 | fwrite | ||
| 57 | getcwd | ||
| 58 | getdomainname | ||
| 59 | getgroups | ||
| 60 | gethostname | ||
| 61 | getlogin_r | ||
| 62 | mbsnrtowcs | ||
| 63 | mbsrtowcs | ||
| 64 | mbstowcs | ||
| 65 | memcpy | ||
| 66 | memmove | ||
| 67 | mempcpy | ||
| 68 | memset | ||
| 69 | poll | ||
| 70 | ppoll | ||
| 71 | pread | ||
| 72 | read | ||
| 73 | readlink | ||
| 74 | readlinkat | ||
| 75 | realpath | ||
| 76 | recv | ||
| 77 | recvfrom | ||
| 78 | send | ||
| 79 | sendto | ||
| 80 | snprintf | ||
| 81 | sprintf | ||
| 82 | stpcpy | ||
| 83 | stpncpy | ||
| 84 | strcat | ||
| 85 | strcpy | ||
| 86 | strlcat | ||
| 87 | strlcpy | ||
| 88 | strncat | ||
| 89 | strncpy | ||
| 90 | ttyname_r | ||
| 91 | vsnprintf | ||
| 92 | vsprintf | ||
| 93 | wcrtomb | ||
| 94 | wcscat | ||
| 95 | wcscpy | ||
| 96 | wcsncat | ||
| 97 | wcsncpy | ||
| 98 | wcsnrtombs | ||
| 99 | wcsrtombs | ||
| 100 | wcstombs | ||
| 101 | wctomb | ||
| 102 | wmemcpy | ||
| 103 | wmemmove | ||
| 104 | wmemset | ||
| 105 | write | ||
| 106 | |||
| 107 | |||
| 108 | [0] http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html | ||
| 109 | [1] http://www.musl-libc.org/ | ||
| 110 | [2] http://git.alpinelinux.org/cgit/aports/commit/?id=067a4f28825478911bb62be3b8da758d9722753e | ||
diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba5d6ec --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | # What is it? | ||
| 2 | |||
| 3 | This is a standalone implementation of | ||
| 4 | [fortify source]( http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html ) | ||
| 5 | based on [the one](https://git.2f30.org/fortify-headers/) from | ||
| 6 | [sin](https://u.2f30.org/sin/). It provides compile time buffer checks. | ||
| 7 | It is libc-agnostic and simply overlays the system headers by using the | ||
| 8 | [`#include_next`](https://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html) | ||
| 9 | extension found in GCC, and | ||
| 10 | [black magic](https://github.com/jvoisin/fortify-headers/commit/fe149628eaae9748be08815d726cc56e8e492c73) | ||
| 11 | on Clang. It was initially intended to be used on | ||
| 12 | [musl](http://www.musl-libc.org/) based | ||
| 13 | [Linux distributions](https://git.alpinelinux.org/aports/commit/?id=067a4f28825478911bb62be3b8da758d9722753e). | ||
| 14 | |||
| 15 | |||
| 16 | # Features | ||
| 17 | |||
| 18 | - It is portable, works on *BSD, Linux, Solaris and possibly others. | ||
| 19 | - It will only trap non-conformant programs. This means that fortify | ||
| 20 | level 2 is treated in the same way as level 1. | ||
| 21 | - Avoids making function calls when undefined behaviour has already been | ||
| 22 | invoked. This is handled by using `__builtin_trap()`. | ||
| 23 | - Support for out-of-bounds read interfaces, such as send(), write(), | ||
| 24 | fwrite() etc. | ||
| 25 | - No ABI is enforced. All of the fortify check functions are inlined | ||
| 26 | into the resulting binary. | ||
| 27 | - It has a [comprehensive suite of tests](https://github.com/jvoisin/fortify-headers/tree/master/tests), | ||
| 28 | running both on Clang and on GCC for every commit, with | ||
| 29 | [significant coverage](https://jvoisin.github.io/fortify-headers/) | ||
| 30 | |||
| 31 | |||
| 32 | # Sample usage | ||
| 33 | |||
| 34 | If you want to quickly test it, you can try something like the following: | ||
| 35 | |||
| 36 | ``` | ||
| 37 | cat > fgets.c <<EOF | ||
| 38 | #include <stdio.h> | ||
| 39 | int | ||
| 40 | main(void) | ||
| 41 | { | ||
| 42 | char buf[BUFSIZ]; | ||
| 43 | fgets(buf, sizeof(buf) + 1, stdin); | ||
| 44 | return 0; | ||
| 45 | } | ||
| 46 | EOF | ||
| 47 | cc -I<path-to-fortify-include-dir> -D_FORTIFY_SOURCE=1 -O1 fgets.c | ||
| 48 | ./a.out | ||
| 49 | ``` | ||
| 50 | |||
| 51 | At this point, the program will safely crash. | ||
| 52 | |||
| 53 | |||
| 54 | # Supported interfaces | ||
| 55 | |||
| 56 | - `FD_CLR` | ||
| 57 | - `FD_SET` | ||
| 58 | - `bcopy` | ||
| 59 | - `bzero` | ||
| 60 | - `confstr` | ||
| 61 | - `fgets` | ||
| 62 | - `fgetws` | ||
| 63 | - `fread` | ||
| 64 | - `fwrite` | ||
| 65 | - `getcwd` | ||
| 66 | - `getdomainname` | ||
| 67 | - `getgroups` | ||
| 68 | - `gethostname` | ||
| 69 | - `getlogin_r` | ||
| 70 | - `mbsnrtowcs` | ||
| 71 | - `mbsrtowcs` | ||
| 72 | - `mbstowcs` | ||
| 73 | - `memcpy` | ||
| 74 | - `memmove` | ||
| 75 | - `mempcpy` | ||
| 76 | - `memset` | ||
| 77 | - `poll` | ||
| 78 | - `ppoll` | ||
| 79 | - `pread` | ||
| 80 | - `read` | ||
| 81 | - `readlink` | ||
| 82 | - `readlinkat` | ||
| 83 | - `realpath` | ||
| 84 | - `recv` | ||
| 85 | - `recvfrom` | ||
| 86 | - `send` | ||
| 87 | - `sendto` | ||
| 88 | - `snprintf` | ||
| 89 | - `sprintf` | ||
| 90 | - `stpcpy` | ||
| 91 | - `stpncpy` | ||
| 92 | - `strcat` | ||
| 93 | - `strchr` | ||
| 94 | - `strcpy` | ||
| 95 | - `strlcat` | ||
| 96 | - `strlcpy` | ||
| 97 | - `strncat` | ||
| 98 | - `strncpy` | ||
| 99 | - `strrchr` | ||
| 100 | - `ttyname_r` | ||
| 101 | - `vsnprintf` | ||
| 102 | - `vsprintf` | ||
| 103 | - `wcrtomb` | ||
| 104 | - `wcscat` | ||
| 105 | - `wcscpy` | ||
| 106 | - `wcsncat` | ||
| 107 | - `wcsncpy` | ||
| 108 | - `wcsnrtombs` | ||
| 109 | - `wcsrtombs` | ||
| 110 | - `wcstombs` | ||
| 111 | - `wctomb` | ||
| 112 | - `wmemcpy` | ||
| 113 | - `wmemmove` | ||
| 114 | - `wmemset` | ||
| 115 | - `write` | ||
