Explorar o código

Kernel: Ensure that an unveil node with no permission is never accepted

Otherwise nodes inheriting from root may still be accessed with
`access(..., F_OK)`.
Also adds a test case to TestKernelUnveil about this behaviour.
Ali Mohammad Pur %!s(int64=4) %!d(string=hai) anos
pai
achega
90de1ded55

+ 1 - 1
Kernel/FileSystem/VirtualFileSystem.cpp

@@ -851,7 +851,7 @@ KResult VFS::validate_path_against_process_veil(StringView path, int options)
         return EINVAL;
         return EINVAL;
 
 
     auto* unveiled_path = find_matching_unveiled_path(path);
     auto* unveiled_path = find_matching_unveiled_path(path);
-    if (!unveiled_path) {
+    if (!unveiled_path || unveiled_path->permissions() == UnveilAccess::None) {
         dbgln("Rejecting path '{}' since it hasn't been unveiled.", path);
         dbgln("Rejecting path '{}' since it hasn't been unveiled.", path);
         dump_backtrace();
         dump_backtrace();
         return ENOENT;
         return ENOENT;

+ 4 - 0
Tests/Kernel/TestKernelUnveil.cpp

@@ -52,4 +52,8 @@ TEST_CASE(test_failures)
     res = unveil("/bin", "w");
     res = unveil("/bin", "w");
     if (res >= 0)
     if (res >= 0)
         FAIL("unveil permitted after unveil state locked");
         FAIL("unveil permitted after unveil state locked");
+
+    res = access("/bin/id", F_OK);
+    if (res == 0)
+        FAIL("access(..., F_OK) permitted after locked veil without relevant unveil");
 }
 }