Merge "[hwasan] Tweak process and thread initialization."
diff --git a/docs/fdsan.md b/docs/fdsan.md
index e186c69..0e6783d 100644
--- a/docs/fdsan.md
+++ b/docs/fdsan.md
@@ -81,7 +81,7 @@
using std::this_thread::sleep_for;
void victim() {
- sleep_for(200ms);
+ sleep_for(300ms);
int fd = dup(STDOUT_FILENO);
sleep_for(200ms);
ssize_t rc = write(fd, "good\n", 5);
@@ -94,7 +94,7 @@
void bystander() {
sleep_for(100ms);
int fd = dup(STDOUT_FILENO);
- sleep_for(200ms);
+ sleep_for(300ms);
close(fd);
}
@@ -116,7 +116,20 @@
}
```
-Running the program above will result in the `write` in `victim` failing, giving us the error:
+When running the program, the threads' executions will be interleaved as follows:
+
+```cpp
+// victim bystander offender
+ int fd = dup(1); // 3
+ close(3);
+ int fd = dup(1); // 3
+ close(3);
+int fd = dup(1); // 3
+ close(3);
+write(3, "good\n") = 😞;
+```
+
+which results in the following output:
fdsan_test: good failed to write?!: Bad file descriptor
diff --git a/libc/bionic/fdsan.cpp b/libc/bionic/fdsan.cpp
index 31ffa96..11ebf52 100644
--- a/libc/bionic/fdsan.cpp
+++ b/libc/bionic/fdsan.cpp
@@ -249,6 +249,12 @@
return "sqlite";
case ANDROID_FDSAN_OWNER_TYPE_ART_FDFILE:
return "ART FdFile";
+ case ANDROID_FDSAN_OWNER_TYPE_DATAGRAMSOCKETIMPL:
+ return "DatagramSocketImpl";
+ case ANDROID_FDSAN_OWNER_TYPE_SOCKETIMPL:
+ return "SocketImpl";
+ case ANDROID_FDSAN_OWNER_TYPE_ZIPARCHIVE:
+ return "ZipArchive";
case ANDROID_FDSAN_OWNER_TYPE_GENERIC_00:
default:
diff --git a/libc/include/android/fdsan.h b/libc/include/android/fdsan.h
index dc2bbd5..ea7689c 100644
--- a/libc/include/android/fdsan.h
+++ b/libc/include/android/fdsan.h
@@ -114,6 +114,15 @@
/* ART FdFile */
ANDROID_FDSAN_OWNER_TYPE_ART_FDFILE = 9,
+
+ /* java.net.DatagramSocketImpl */
+ ANDROID_FDSAN_OWNER_TYPE_DATAGRAMSOCKETIMPL = 10,
+
+ /* java.net.SocketImpl */
+ ANDROID_FDSAN_OWNER_TYPE_SOCKETIMPL = 11,
+
+ /* libziparchive's ZipArchive */
+ ANDROID_FDSAN_OWNER_TYPE_ZIPARCHIVE = 12,
};
/*