summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-01 09:23:46 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-01 10:56:17 +0100
commitc44b4d61f350703fcf1bbd8f6e353b9c6c4210c2 (patch)
tree0606651fd0fce5148286f20f7c67a00b7d1383cf /Tests
parent5aa37f6f5c9026346e8dbc7db26cf73516a7a876 (diff)
downloadserenity-c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2.zip
Kernel: Make Inode::lookup() return a RefPtr<Inode>
Previously this API would return an InodeIdentifier, which meant that there was a race in path resolution where an inode could be unlinked in between finding the InodeIdentifier for a path component, and actually resolving that to an Inode object. Attaching a test that would quickly trip an assertion before. Test: Kernel/path-resolution-race.cpp
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Kernel/path-resolution-race.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/Kernel/path-resolution-race.cpp b/Tests/Kernel/path-resolution-race.cpp
new file mode 100644
index 0000000000..804fbc1b52
--- /dev/null
+++ b/Tests/Kernel/path-resolution-race.cpp
@@ -0,0 +1,16 @@
+#include <unistd.h>
+#include <sys/stat.h>
+
+int main()
+{
+ if (!fork()) {
+ for (;;) {
+ mkdir("/tmp/x", 0666);
+ rmdir("/tmp/x");
+ }
+ }
+ for (;;) {
+ chdir("/tmp/x");
+ }
+ return 0;
+}