summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-05-01 13:13:47 -0700
committerElliott Hughes <enh@google.com>2018-05-01 13:13:47 -0700
commit07f62385b65856552ad8f1019e4261df3badc5cb (patch)
treeb0b16aa12e470f2e1edcc0f59fd48ec37118551a /docs
parent67b5979930ba81477cf5f835b1fe23563ee9c761 (diff)
Document FORTIFY.
Hilariously, our blog post didn't actually say how to turn it on :-) Bug: N/A Test: N/A Change-Id: I6e773e88c32a70b0f8b8b6d105fce74d68ebf5cd
Diffstat (limited to 'docs')
-rw-r--r--docs/status.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/status.md b/docs/status.md
index a0e682461..e81ac7ed8 100644
--- a/docs/status.md
+++ b/docs/status.md
@@ -173,3 +173,31 @@ signal. This wasn't historically true in Android, and when we fixed this
bug we found that existing code relied on the old behavior. To preserve
compatibility, `sem_wait` can only return EINTR on Android if the app
targets N or later.
+
+
+## FORTIFY
+
+The `_FORTIFY_SOURCE` macro can be used to enable extra
+automatic bounds checking for common libc functions. If a buffer
+overrun is detected, the program is safely aborted as in this
+(example)[https://source.android.com/devices/tech/debug/native-crash#fortify].
+
+Note that in recent releases Android's FORTIFY has been extended to
+cover other issues. It can now detect, for example, passing `O_CREAT`
+to open(2) without specifying a mode. It also performs some checking
+regardless of whether the caller was built with FORTIFY enabled. In P,
+for example, calling a `pthread_mutex_` function on a destroyed mutex,
+calling a `<dirent.h>` function on a null pointer, using `%n` with the
+printf(3) family, or using the scanf(3) `m` modifier incorrectly will
+all result in FORTIFY failures even for code not built with FORTIFY.
+
+More background information is available in our
+(FORTIFY in Android)[https://android-developers.googleblog.com/2017/04/fortify-in-android.html]
+blog post.
+
+The Android platform is built with `-D_FORTIFY_SOURCE=2`, but NDK users
+need to manually enable FORTIFY by setting that themselves in whatever
+build system they're using. The exact subset of FORTIFY available to
+NDK users will depend on their target ABI level, because when a FORTIFY
+check can't be guaranteed at compile-time, a call to a run-time `_chk`
+function is added.