feat(libSceNKWebKit): implement the WTF path and directory operations #14949

Closed
w4rc0n wants to merge 1 commit from upstream-pr/14949 into main
w4rc0n commented 2026-11-02 03:15:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by w4rc0n on 2026-11-02T03:15:14Z.


What

Six WTF::FileSystemImpl path and directory functions were NotImplemented stubs. They now follow the pinned PS5 WebKit 11.x source, and do all their work on guest paths through AnyPS5's existing guest providers, with no host-path bypass:

  • fileExists follows symlinks, through guest stat (libkernel File/src/Stdio.cpp:1131).
  • deleteFile uses guest lstat (:1139) and unlink (:1152) to tell files and symlinks from directories, and refuses directories as the source does.
  • deleteEmptyDirectory applies the source's symlink check, then guest rmdir (:1677).
  • makeAllDirectories creates each missing parent with guest stat and mkdir at mode 0777 (:1023), handling ENOENT and EEXIST. It splits the path on slashes only, with no host normalization.
  • moveFile is rename on PlayStation (FileSystemPlayStation.cpp:60-70), through libc's existing RenameGuestPath_nid_no_patch (libc/src/Rename.cpp:137), the helper that libc's guest rename export wraps (:180-182). It is called directly because libkernel also compiles that file and keeps rename_nid_postfix under its plain name while NKWebKit's import of it is patched to the NID. On Windows the import binds to libkernel and the library failed to load with error 127; Linux's global symbol lookup hid that.
  • realPath uses libc's guest realpath (RealPath.cpp:217), which returns a guest path. On failure it returns the original string (FileSystemPlayStation.cpp:139-144).

These functions inherit the providers' current gaps, such as the parts of mutation, lstat and realpath that don't yet handle archives. They don't work around them. Links and filesHaveSameVolume are later work. lastComponentOfPathIgnoringTrailingSlash is left to #14858, which implements it.

tools/pr_overlap.py on this head, with main at 0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge with main, GitHub's file lists show none of them changing these exports either. #13947, #13992, #14981, #15011, #15215 and #15498 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14932, in the same stack.

Tested

Debian 12, GCC 12.2, Linux 6.18, Release, at the head 10590b54e756b0b48baf1f6d515f365ba22d1530. It is on #14931's head 0efdf47930434f6317c4a572ea0af7cf501e0095. The selection was the thirteen NKWebKit tests (nkwebkit_constants and upstream's newer nkwebkit_fastbitvector, nkwebkit_resourceresponse, guest_nkwebkit_urls and nkwebkit_palsessionid included), public_headers and patched_libraries, and the full libs target was built.

  • Unmodified: 14 of 15 pass, including patched_libraries. nkwebkit_wtf aborts with guest path: process_vm_readv failed with errno 38 once it reaches a guest path. Its lexical checks run before that. This machine's kernel has no process_vm_readv; the Linux CI run below reaches it.
  • With the local fallback below (not part of this PR): 15 of 15 pass. The new nkwebkit_wtf cases cover:
    • existence of files, directories and missing paths;
    • deleting a file versus a directory;
    • moving over an existing file and into a missing parent;
    • nested and existing makeAllDirectories;
    • deleteEmptyDirectory on non-empty, symlink and missing paths;
    • realPath through an alias and on a missing path;
    • directories created under a setgid parent. The test sets set_gid on its temporary root, and checks the new directories' mode with perms::all, since they inherit S_ISGID. XairRrR's review found that the earlier perms::mask check failed in a setgid build directory. With the local fallback, the previous head's check aborts under this fixture (the new directories read 02777), and perms::all passes.
  • At the head, libSceNKWebKit.prx lists libkernel.prx as needed, and ldd -r reports no undefined symbols.
  • The patched libSceNKWebKit.prx imports RenameGuestPath_nid_no_patch and no rename NID.
  • tools/progress.py: the six exports count as implemented (libSceNKWebKit 1324, against 1318 with #14931).
  • tools/check_conventions.py passes.
  • Windows (GitHub-hosted CI in the author's fork): run 41376713519 built this branch's previous head d82592c45b330f97325194d1223c930fb41e1ab9. It is AnyPS5's Build workflow, dispatched in the author's fork with select=true: the branch merged into main at 93dbd0f82aea684e95f15f06e7d42c0064af18cf, built on windows-latest with WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, which check_skips.py accepts. That includes the nine NKWebKit tests, public_headers and patched_libraries. The first attempt of run 41376713519 timed out two unrelated check_compile_modes_test_clang_* tool tests at 30 s, which pass in 2-3 s in every other run; the failed job was rerun and passed. Since that run, the rebases onto main (now 0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #14479, #15228, #13766, #14925 and #15911) changed only docs/dev/debt/libSceNKWebKit.md, and the review fix changed only the directory-mode check and its setgid fixture in tests/Wtf.cpp, so git range-diff shows the production code is the same as at that run. A fork-internal pull request existed only to give the workflow a number.
  • Linux, unmodified, on a normal kernel (GitHub-hosted CI in the author's fork): a fork-only workflow, not part of this PR (run 41618954287), built this branch's previous head c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939 with the full libs target on ubuntu-latest (Ubuntu 24.04, kernel 7.0, GCC 13.3). 13 of 13 pass, including nkwebkit_wtf (with the setgid fixture) and patched_libraries. The later rebases onto main (now 0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #13766, #14925 and #15911) changed only docs/dev/debt/libSceNKWebKit.md, so git range-diff shows the code and tests under test are the same as at that run.
Local fallback used for the second run (not in this PR)
diff --git a/core/libs/prx/libc/src/General.cpp b/core/libs/prx/libc/src/General.cpp
index 9ed57a5fb0..dbb7e1201b 100644
--- a/core/libs/prx/libc/src/General.cpp
+++ b/core/libs/prx/libc/src/General.cpp
@@ -83,6 +83,23 @@ std::size_t HostPageSize() {
     return size;
 }
 
+static bool ReviewPipeCopy(void* destination, const void* source, std::size_t bytes) {
+    int fds[2];
+    if (::pipe(fds) != 0) throw std::runtime_error("review shim: pipe failed");
+    bool ok = true;
+    for (std::size_t done = 0; done < bytes;) {
+        const std::size_t chunk = std::min<std::size_t>(bytes - done, 4096);
+        const ssize_t written = ::write(fds[1], static_cast<const char*>(source) + done, chunk);
+        if (written <= 0) { ok = false; break; }
+        const ssize_t read = ::read(fds[0], static_cast<char*>(destination) + done, static_cast<std::size_t>(written));
+        if (read != written) { ok = false; break; }
+        done += static_cast<std::size_t>(written);
+    }
+    ::close(fds[0]);
+    ::close(fds[1]);
+    return ok;
+}
+
 bool CopyGuestBytes(void* destination, const void* source, std::size_t bytes) {
     GuestArena::GuestArenaPrepareHostRead_nid_no_patch(source, bytes);
 #ifdef _WIN32
@@ -92,6 +109,7 @@ bool CopyGuestBytes(void* destination, const void* source, std::size_t bytes) {
     iovec local{destination, bytes};
     iovec remote{const_cast<void*>(source), bytes};
     const auto copied = process_vm_readv(getpid(), &local, 1, &remote, 1, 0);
+    if (copied < 0 && errno == ENOSYS) return ReviewPipeCopy(destination, source, bytes);
     if (copied < 0 && errno != EFAULT) throw std::runtime_error("guest path: process_vm_readv failed with errno " + std::to_string(errno));
     return copied >= 0 && static_cast<std::size_t>(copied) == bytes;
 #elif defined(__APPLE__)
@@ -840,6 +858,7 @@ extern "C" bool GuestCopyOut_nid_no_patch(void* destination, const void* source,
     iovec local{const_cast<void*>(source), bytes};
     iovec remote{destination, bytes};
     const ssize_t copied = ::process_vm_writev(::getpid(), &local, 1, &remote, 1, 0);
+    if (copied < 0 && errno == ENOSYS) return ReviewPipeCopy(destination, source, bytes);
     if (copied < 0) {
         if (errno == EFAULT) return false;
         throw std::runtime_error("GuestCopyOut: process_vm_writev failed with errno " + std::to_string(errno));

Not built or run: macOS. The permission and symlink cases run on Linux only. No title or homebrew was run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #14931
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5114389321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949). Originally posted by [w4rc0n](https://github.com/w4rc0n) on 2026-11-02T03:15:14Z. --- ### What Six `WTF::FileSystemImpl` path and directory functions were `NotImplemented` stubs. They now follow the pinned PS5 WebKit 11.x source, and do all their work on guest paths through AnyPS5's existing guest providers, with no host-path bypass: - [`fileExists`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/FileSystem.cpp#L852-L876) follows symlinks, through guest `stat` (libkernel `File/src/Stdio.cpp:1131`). - `deleteFile` uses guest `lstat` (`:1139`) and `unlink` (`:1152`) to tell files and symlinks from directories, and refuses directories as the source does. - [`deleteEmptyDirectory`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/FileSystem.cpp#L613-L639) applies the source's symlink check, then guest `rmdir` (`:1677`). - `makeAllDirectories` creates each missing parent with guest `stat` and `mkdir` at mode 0777 (`:1023`), handling `ENOENT` and `EEXIST`. It splits the path on slashes only, with no host normalization. - `moveFile` is `rename` on PlayStation ([`FileSystemPlayStation.cpp:60-70`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/playstation/FileSystemPlayStation.cpp#L60-L70)), through libc's existing `RenameGuestPath_nid_no_patch` (`libc/src/Rename.cpp:137`), the helper that libc's guest `rename` export wraps (`:180-182`). It is called directly because libkernel also compiles that file and keeps `rename_nid_postfix` under its plain name while NKWebKit's import of it is patched to the NID. On Windows the import binds to libkernel and the library failed to load with error 127; Linux's global symbol lookup hid that. - `realPath` uses libc's guest `realpath` (`RealPath.cpp:217`), which returns a guest path. On failure it returns the original string ([`FileSystemPlayStation.cpp:139-144`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/playstation/FileSystemPlayStation.cpp#L139-L144)). These functions inherit the providers' current gaps, such as the parts of mutation, `lstat` and `realpath` that don't yet handle archives. They don't work around them. Links and `filesHaveSameVolume` are later work. `lastComponentOfPathIgnoringTrailingSlash` is left to #14858, which implements it. `tools/pr_overlap.py` on this head, with `main` at `0eba5db30d`: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge with `main`, GitHub's file lists show none of them changing these exports either. #13947, #13992, #14981, #15011, #15215 and #15498 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14932, in the same stack. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Debian 12, GCC 12.2, Linux 6.18, Release, at the head `10590b54e756b0b48baf1f6d515f365ba22d1530`. It is on #14931's head `0efdf47930434f6317c4a572ea0af7cf501e0095`. The selection was the thirteen NKWebKit tests (`nkwebkit_constants` and upstream's newer `nkwebkit_fastbitvector`, `nkwebkit_resourceresponse`, `guest_nkwebkit_urls` and `nkwebkit_palsessionid` included), `public_headers` and `patched_libraries`, and the full `libs` target was built. - **Unmodified:** 14 of 15 pass, including `patched_libraries`. `nkwebkit_wtf` aborts with `guest path: process_vm_readv failed with errno 38` once it reaches a guest path. Its lexical checks run before that. This machine's kernel has no `process_vm_readv`; the Linux CI run below reaches it. - **With the local fallback below (not part of this PR):** 15 of 15 pass. The new `nkwebkit_wtf` cases cover: - existence of files, directories and missing paths; - deleting a file versus a directory; - moving over an existing file and into a missing parent; - nested and existing `makeAllDirectories`; - `deleteEmptyDirectory` on non-empty, symlink and missing paths; - `realPath` through an alias and on a missing path; - directories created under a setgid parent. The test sets `set_gid` on its temporary root, and checks the new directories' mode with `perms::all`, since they inherit `S_ISGID`. [XairRrR's review](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5750281946) found that the earlier `perms::mask` check failed in a setgid build directory. With the local fallback, the previous head's check aborts under this fixture (the new directories read `02777`), and `perms::all` passes. - At the head, `libSceNKWebKit.prx` lists `libkernel.prx` as needed, and `ldd -r` reports no undefined symbols. - The patched `libSceNKWebKit.prx` imports `RenameGuestPath_nid_no_patch` and no `rename` NID. - `tools/progress.py`: the six exports count as implemented (libSceNKWebKit 1324, against 1318 with #14931). - `tools/check_conventions.py` passes. - **Windows (GitHub-hosted CI in the author's fork):** [run 41376713519](https://github.com/w4rc0n/AnyPS5/actions/runs/41376713519) built this branch's previous head `d82592c45b330f97325194d1223c930fb41e1ab9`. It is AnyPS5's `Build` workflow, dispatched in the author's fork with `select=true`: the branch merged into `main` at `93dbd0f82aea684e95f15f06e7d42c0064af18cf`, built on `windows-latest` with WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, which `check_skips.py` accepts. That includes the nine NKWebKit tests, `public_headers` and `patched_libraries`. The first attempt of run 41376713519 timed out two unrelated `check_compile_modes_test_clang_*` tool tests at 30 s, which pass in 2-3 s in every other run; the failed job was rerun and passed. Since that run, the rebases onto `main` (now `0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4`, after #14479, #15228, #13766, #14925 and #15911) changed only `docs/dev/debt/libSceNKWebKit.md`, and the review fix changed only the directory-mode check and its setgid fixture in `tests/Wtf.cpp`, so `git range-diff` shows the production code is the same as at that run. A fork-internal pull request existed only to give the workflow a number. - **Linux, unmodified, on a normal kernel (GitHub-hosted CI in the author's fork):** a fork-only workflow, not part of this PR ([run 41618954287](https://github.com/w4rc0n/AnyPS5/actions/runs/41618954287)), built this branch's previous head `c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939` with the full `libs` target on `ubuntu-latest` (Ubuntu 24.04, kernel 7.0, GCC 13.3). 13 of 13 pass, including `nkwebkit_wtf` (with the setgid fixture) and `patched_libraries`. The later rebases onto `main` (now `0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4`, after #13766, #14925 and #15911) changed only `docs/dev/debt/libSceNKWebKit.md`, so `git range-diff` shows the code and tests under test are the same as at that run. <details><summary>Local fallback used for the second run (not in this PR)</summary> ```diff diff --git a/core/libs/prx/libc/src/General.cpp b/core/libs/prx/libc/src/General.cpp index 9ed57a5fb0..dbb7e1201b 100644 --- a/core/libs/prx/libc/src/General.cpp +++ b/core/libs/prx/libc/src/General.cpp @@ -83,6 +83,23 @@ std::size_t HostPageSize() { return size; } +static bool ReviewPipeCopy(void* destination, const void* source, std::size_t bytes) { + int fds[2]; + if (::pipe(fds) != 0) throw std::runtime_error("review shim: pipe failed"); + bool ok = true; + for (std::size_t done = 0; done < bytes;) { + const std::size_t chunk = std::min<std::size_t>(bytes - done, 4096); + const ssize_t written = ::write(fds[1], static_cast<const char*>(source) + done, chunk); + if (written <= 0) { ok = false; break; } + const ssize_t read = ::read(fds[0], static_cast<char*>(destination) + done, static_cast<std::size_t>(written)); + if (read != written) { ok = false; break; } + done += static_cast<std::size_t>(written); + } + ::close(fds[0]); + ::close(fds[1]); + return ok; +} + bool CopyGuestBytes(void* destination, const void* source, std::size_t bytes) { GuestArena::GuestArenaPrepareHostRead_nid_no_patch(source, bytes); #ifdef _WIN32 @@ -92,6 +109,7 @@ bool CopyGuestBytes(void* destination, const void* source, std::size_t bytes) { iovec local{destination, bytes}; iovec remote{const_cast<void*>(source), bytes}; const auto copied = process_vm_readv(getpid(), &local, 1, &remote, 1, 0); + if (copied < 0 && errno == ENOSYS) return ReviewPipeCopy(destination, source, bytes); if (copied < 0 && errno != EFAULT) throw std::runtime_error("guest path: process_vm_readv failed with errno " + std::to_string(errno)); return copied >= 0 && static_cast<std::size_t>(copied) == bytes; #elif defined(__APPLE__) @@ -840,6 +858,7 @@ extern "C" bool GuestCopyOut_nid_no_patch(void* destination, const void* source, iovec local{const_cast<void*>(source), bytes}; iovec remote{destination, bytes}; const ssize_t copied = ::process_vm_writev(::getpid(), &local, 1, &remote, 1, 0); + if (copied < 0 && errno == ENOSYS) return ReviewPipeCopy(destination, source, bytes); if (copied < 0) { if (errno == EFAULT) return false; throw std::runtime_error("GuestCopyOut: process_vm_writev failed with errno " + std::to_string(errno)); ``` </details> Not built or run: macOS. The permission and symlink cases run on Linux only. No title or homebrew was run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #14931 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-02 16:54:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T16:54:58Z.

Review: APPROVED


Build and test on Windows (WinLibs GCC, BUILD_TESTING=ON), PR merged into current main: nkwebkit_wtf passes. With the PR's source file taken from main, the test executable doesn't link, since the exports are new, so there's no main control.

The six functions go through the existing guest providers (stat, lstat, unlink, rmdir, mkdir, RenameGuestPath_nid_no_patch, guest realpath), with no host-path bypass, and realPath returns the original string on failure as FileSystemPlayStation.cpp does. Calling RenameGuestPath_nid_no_patch directly, rather than going through the NID-patched rename import, is a sound fix for the Windows load error 127 the PR describes.

I didn't compare these against the firmware module. The approval rests on the pinned WebKit source and the passing test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5740145155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5740145155). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T16:54:58Z. **Review:** APPROVED --- Build and test on Windows (WinLibs GCC, `BUILD_TESTING=ON`), PR merged into current `main`: `nkwebkit_wtf` passes. With the PR's source file taken from `main`, the test executable doesn't link, since the exports are new, so there's no `main` control. The six functions go through the existing guest providers (`stat`, `lstat`, `unlink`, `rmdir`, `mkdir`, `RenameGuestPath_nid_no_patch`, guest `realpath`), with no host-path bypass, and `realPath` returns the original string on failure as `FileSystemPlayStation.cpp` does. Calling `RenameGuestPath_nid_no_patch` directly, rather than going through the NID-patched `rename` import, is a sound fix for the Windows load error 127 the PR describes. I didn't compare these against the firmware module. The approval rests on the pinned WebKit source and the passing test.
XairRrR commented 2026-11-03 10:05:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:05:51Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The six path and directory functions follow the pinned WebKit source and use the guest providers. The new nkwebkit_wtf test fails here, though, because a permission check on the directory it creates also compares the setgid bit.

What I ran

Head 4726a384e8bd999342f9836aa4a3a5d62b3a4d4a, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 21667d859ad63faecd7ea397a386110ca934b307. Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...4726a384e8bd999342f9836aa4a3a5d62b3a4d4a
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build --output-on-failure -R "^nkwebkit_wtf$"
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "nkwebkit|public_headers|patched_libraries"
# diagnosis: Require() in tests/Wtf.cpp temporarily prints std::source_location, then rebuilt and ran
ninja -C build nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests
# same, with the assertion at Wtf.cpp:508 masked by perms::all instead of perms::mask
ninja -C build nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests
# negative control: src/WtfSystem.cpp from main
ninja -C build nkwebkit_wtf_tests
# restored all files to the merged tree, rebuilt nkwebkit_wtf_tests and libSceNKWebKit
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure, build, libs (script) OK
nkwebkit_wtf fails (aborts, exit 134), only on this PR, not in main's baseline
Other NKWebKit tests, public_headers_*, patched_libraries (76 tests) pass
nkwebkit_wtf with line 508 masked by perms::all passes (exit 0), file-handle and path cases included
unwrap_self_..._inherits_the_destination_directory_group known failure on main, not caused by this PR
Failure, with Require() printing its line (instrumented file, one line below the original)
Require failed line 509
Aborted

In the unmodified file this is line 508, the check of the permissions on root / "a" / "b".

Why: the build directory has the setgid bit
$ stat -c "%a %n" build
2775 .
$ python3 -c 'os.umask(0); os.mkdir("build/zz", 0o777); print(oct(os.stat("build/zz").st_mode))'
0o42777

Negative control

With core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp taken from main, nkwebkit_wtf_tests does not link: there are undefined references to WTF::FileSystemImpl::fileExists, deleteFile, deleteEmptyDirectory, realPath, makeAllDirectories and the others. The exports are new, so this is the only control possible, as BunnyFl also found on Windows. Afterwards I restored the merged files and rebuilt. git status --porcelain is empty.

Findings

Blocking

  1. The makeAllDirectories mode check fails under a setgid parent directory. It is at tests/Wtf.cpp:508.
    • What fails: the test masks the new directory's permissions with std::filesystem::perms::mask (07777) and expects exactly 0777.
    • Why: on Linux, a directory made inside a setgid directory inherits S_ISGID. The guest mkdir correctly gives 02777, so the comparison fails and nkwebkit_wtf aborts with no message. That happens in this review's build tree, and in any shared or group-owned checkout with g+s. The implementation itself behaves correctly.
    • Fix: mask with std::filesystem::perms::all (0777), which is what the assertion means to check. With that one change the whole test passes here. The file checks at the other perms::mask sites are unaffected, because regular files don't inherit setgid, and they passed here.

Non-blocking

None.

Not verified

  • Windows and macOS: I did not run either. The description cites a Windows CI run of the previous head, and BunnyFl's review reports a Windows pass.
  • Firmware behaviour: I did not compare the module's behaviour against firmware. I checked the semantics only against WebKit's generic and PlayStation FileSystem behaviour: deleteFile refuses directories via lstat, moveFile is rename, and realPath returns the input on failure.
  • #14931 commit: this PR also contains #14931's file-handle commit (openFile, seekFile, and the others). I only exercised those through the shared test. I did not review that commit's semantics beyond the test.
  • Validation layer: none of the changed files is in the AGC driver, the shader recompiler or VideoOut, so the script skipped the validation-layer comparison.

To get this to a good state

  • In core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:508, replace std::filesystem::perms::mask with std::filesystem::perms::all, then rerun nkwebkit_wtf.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5750281946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5750281946). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T10:05:51Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The six path and directory functions follow the pinned WebKit source and use the guest providers. The new `nkwebkit_wtf` test fails here, though, because a permission check on the directory it creates also compares the setgid bit. ## What I ran Head `4726a384e8bd999342f9836aa4a3a5d62b3a4d4a`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `21667d859ad63faecd7ea397a386110ca934b307`. Debian 13 VM, GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...4726a384e8bd999342f9836aa4a3a5d62b3a4d4a python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build --output-on-failure -R "^nkwebkit_wtf$" ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "nkwebkit|public_headers|patched_libraries" # diagnosis: Require() in tests/Wtf.cpp temporarily prints std::source_location, then rebuilt and ran ninja -C build nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests # same, with the assertion at Wtf.cpp:508 masked by perms::all instead of perms::mask ninja -C build nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests # negative control: src/WtfSystem.cpp from main ninja -C build nkwebkit_wtf_tests # restored all files to the merged tree, rebuilt nkwebkit_wtf_tests and libSceNKWebKit git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure, build, `libs` (script) | OK | | `nkwebkit_wtf` | **fails** (aborts, exit 134), only on this PR, not in `main`'s baseline | | Other NKWebKit tests, `public_headers_*`, `patched_libraries` (76 tests) | pass | | `nkwebkit_wtf` with line 508 masked by `perms::all` | passes (exit 0), file-handle and path cases included | | `unwrap_self_..._inherits_the_destination_directory_group` | known failure on `main`, not caused by this PR | <details><summary>Failure, with Require() printing its line (instrumented file, one line below the original)</summary> ``` Require failed line 509 Aborted ``` In the unmodified file this is line 508, the check of the permissions on `root / "a" / "b"`. </details> <details><summary>Why: the build directory has the setgid bit</summary> ``` $ stat -c "%a %n" build 2775 . $ python3 -c 'os.umask(0); os.mkdir("build/zz", 0o777); print(oct(os.stat("build/zz").st_mode))' 0o42777 ``` </details> ## Negative control With `core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp` taken from `main`, `nkwebkit_wtf_tests` does not link: there are undefined references to `WTF::FileSystemImpl::fileExists`, `deleteFile`, `deleteEmptyDirectory`, `realPath`, `makeAllDirectories` and the others. The exports are new, so this is the only control possible, as BunnyFl also found on Windows. Afterwards I restored the merged files and rebuilt. `git status --porcelain` is empty. ## Findings ### Blocking 1. **The `makeAllDirectories` mode check fails under a setgid parent directory.** It is at [`tests/Wtf.cpp:508`](https://github.com/boykopovar/AnyPS5/blob/4726a384e8bd999342f9836aa4a3a5d62b3a4d4a/core/libs/prx/libSceNKWebKit/tests/Wtf.cpp#L508). - **What fails:** the test masks the new directory's permissions with `std::filesystem::perms::mask` (07777) and expects exactly 0777. - **Why:** on Linux, a directory made inside a setgid directory inherits `S_ISGID`. The guest `mkdir` correctly gives 02777, so the comparison fails and `nkwebkit_wtf` aborts with no message. That happens in this review's build tree, and in any shared or group-owned checkout with `g+s`. The implementation itself behaves correctly. - **Fix:** mask with `std::filesystem::perms::all` (0777), which is what the assertion means to check. With that one change the whole test passes here. The file checks at the other `perms::mask` sites are unaffected, because regular files don't inherit setgid, and they passed here. ### Non-blocking None. ## Not verified - **Windows and macOS:** I did not run either. The description cites a Windows CI run of the previous head, and BunnyFl's review reports a Windows pass. - **Firmware behaviour:** I did not compare the module's behaviour against firmware. I checked the semantics only against WebKit's generic and PlayStation `FileSystem` behaviour: `deleteFile` refuses directories via `lstat`, `moveFile` is `rename`, and `realPath` returns the input on failure. - **#14931 commit:** this PR also contains #14931's file-handle commit (`openFile`, `seekFile`, and the others). I only exercised those through the shared test. I did not review that commit's semantics beyond the test. - **Validation layer:** none of the changed files is in the AGC driver, the shader recompiler or VideoOut, so the script skipped the validation-layer comparison. ## To get this to a good state - In `core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:508`, replace `std::filesystem::perms::mask` with `std::filesystem::perms::all`, then rerun `nkwebkit_wtf`. <!-- anyps5-bots job=2744 head=4726a384e8bd999342f9836aa4a3a5d62b3a4d4a -->
XairRrR commented 2026-11-03 10:55:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:55:08Z.

Review: APPROVED


Re-checked — approved

The new head fixes the blocking test failure. In tests/Wtf.cpp the directory-mode check now masks with perms::all, and the test sets setgid on its own temporary root, so the inherited-S_ISGID case runs on every host.

What changed since my last review

  • Code: the range-diff from 4726a384 to c6239ff3 changes only core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:
    • On non-Windows hosts, std::filesystem::permissions(root, perms::set_gid, perm_options::add) runs on the temporary root (L494-L496).
    • The makeAllDirectories mode check masks with perms::all instead of perms::mask (L511).
    • Commit 1 (#14931's file-handle commit) and all production code are unchanged.
  • Description: it now describes the setgid fixture and cites a hosted-Linux run of this head. I accept that run as author-reported.

What I ran

Head c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 9cbbd5dd6538f02f45461442039f97ff6127c700. Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "nkwebkit|public_headers|patched_libraries"
# fixture check: Wtf.cpp:511 temporarily set back to perms::mask, run from a 0755 directory (no setgid)
ninja -C build -j32 -l32 nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests
# merged Wtf.cpp restored, rebuilt, run again from the same 0755 directory and through ctest
ninja -C build -j32 -l32 nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests
ctest --test-dir build --output-on-failure -R "^nkwebkit_wtf$"
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure, build, libs (script) OK
Script's test run (831 tests) 0 new failures, 0 timeouts. 1 known main failure (unwrap_self_..._inherits_the_destination_directory_group), not caused by this PR
NKWebKit, public_headers_*, patched_libraries (77 tests) all pass. The build directory is still 2775 (setgid), the case that failed last time
nkwebkit_wtf with the old perms::mask check, run from a non-setgid directory aborts (exit 134)
nkwebkit_wtf at the head, run from the same directory passes (exit 0) and leaves no temporary directory behind

Previous findings

  1. The makeAllDirectories mode check fails under a setgid parent (tests/Wtf.cpp:508 at 4726a38): Resolved.
    • The check at line 511 now masks with perms::all, and nkwebkit_wtf passes in this review's setgid build tree.
    • Putting the old perms::mask check back makes the test abort even when it runs from a directory without setgid. So the new fixture reproduces the case on any checkout, as the author said in their reply.

Negative control

  • Production code: the exports are new, so with src/WtfSystem.cpp taken from main the test does not link. I recorded that in my last review, and the production code has not changed since, so I did not repeat it.
  • New fixture: I reverted only the changed assertion, as described above. The test fails with it and passes without it.
  • Cleanup: I restored the merged file and rebuilt. git status --porcelain is empty.

New findings

None.

Not verified

  • Windows and macOS: not run here. The Windows CI run in the description is of an earlier head, and the description says the production code is identical since then. BunnyFl's approval reports a Windows pass.
  • Firmware behaviour: not compared against the firmware module. I checked the semantics only against the pinned WebKit generic and PlayStation FileSystem sources.
  • #14931's file-handle commit: exercised only through the shared test. I did not review it separately.
  • Validation layer: no changed file is under the AGC driver, the shader recompiler or VideoOut, so the script skipped the validation-layer comparison.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5750923396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5750923396). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T10:55:08Z. **Review:** APPROVED --- # Re-checked — approved The new head fixes the blocking test failure. In `tests/Wtf.cpp` the directory-mode check now masks with `perms::all`, and the test sets setgid on its own temporary root, so the inherited-`S_ISGID` case runs on every host. ## What changed since my last review - **Code:** the range-diff from `4726a384` to `c6239ff3` changes only `core/libs/prx/libSceNKWebKit/tests/Wtf.cpp`: - On non-Windows hosts, `std::filesystem::permissions(root, perms::set_gid, perm_options::add)` runs on the temporary root ([L494-L496](https://github.com/boykopovar/AnyPS5/blob/c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939/core/libs/prx/libSceNKWebKit/tests/Wtf.cpp#L494-L496)). - The `makeAllDirectories` mode check masks with `perms::all` instead of `perms::mask` ([L511](https://github.com/boykopovar/AnyPS5/blob/c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939/core/libs/prx/libSceNKWebKit/tests/Wtf.cpp#L511)). - Commit 1 (#14931's file-handle commit) and all production code are unchanged. - **Description:** it now describes the setgid fixture and cites a hosted-Linux run of this head. I accept that run as author-reported. ## What I ran Head `c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `9cbbd5dd6538f02f45461442039f97ff6127c700`. Debian 13 VM, GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "nkwebkit|public_headers|patched_libraries" # fixture check: Wtf.cpp:511 temporarily set back to perms::mask, run from a 0755 directory (no setgid) ninja -C build -j32 -l32 nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests # merged Wtf.cpp restored, rebuilt, run again from the same 0755 directory and through ctest ninja -C build -j32 -l32 nkwebkit_wtf_tests && build/tests/nkwebkit_wtf_tests ctest --test-dir build --output-on-failure -R "^nkwebkit_wtf$" git status --porcelain ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure, build, `libs` (script) | OK | | Script's test run (831 tests) | 0 new failures, 0 timeouts. 1 known `main` failure (`unwrap_self_..._inherits_the_destination_directory_group`), not caused by this PR | | NKWebKit, `public_headers_*`, `patched_libraries` (77 tests) | all pass. The build directory is still `2775` (setgid), the case that failed last time | | `nkwebkit_wtf` with the old `perms::mask` check, run from a non-setgid directory | aborts (exit 134) | | `nkwebkit_wtf` at the head, run from the same directory | passes (exit 0) and leaves no temporary directory behind | ## Previous findings 1. **The `makeAllDirectories` mode check fails under a setgid parent** (`tests/Wtf.cpp:508` at `4726a38`): **Resolved.** - The check at line 511 now masks with `perms::all`, and `nkwebkit_wtf` passes in this review's setgid build tree. - Putting the old `perms::mask` check back makes the test abort even when it runs from a directory without setgid. So the new fixture reproduces the case on any checkout, as the author said in their reply. ## Negative control - **Production code:** the exports are new, so with `src/WtfSystem.cpp` taken from `main` the test does not link. I recorded that in my last review, and the production code has not changed since, so I did not repeat it. - **New fixture:** I reverted only the changed assertion, as described above. The test fails with it and passes without it. - **Cleanup:** I restored the merged file and rebuilt. `git status --porcelain` is empty. ## New findings None. ## Not verified - **Windows and macOS:** not run here. The Windows CI run in the description is of an earlier head, and the description says the production code is identical since then. BunnyFl's approval reports a Windows pass. - **Firmware behaviour:** not compared against the firmware module. I checked the semantics only against the pinned WebKit generic and PlayStation `FileSystem` sources. - **#14931's file-handle commit:** exercised only through the shared test. I did not review it separately. - **Validation layer:** no changed file is under the AGC driver, the shader recompiler or VideoOut, so the script skipped the validation-layer comparison. <!-- anyps5-bots job=3291 head=c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939 -->
BunnyFl commented 2026-11-04 15:39:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T15:39:42Z.

Review: APPROVED


@w4rc0n re-checked at e4db024ffc. git range-diff of my approved d82592c45b against this head shows one change to this PR's own patch, in the test, which is the fix for XairRrR's finding:

  • The directory-mode check masks with perms::all (core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:511).
  • Off Windows, the test sets setgid on its own temporary root first (:495). An inherited S_ISGID then no longer depends on the checkout's group.

The library code is unchanged.

What I ran: head e4db024ffc (it already contains main b11c7bf84f), Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON:

  • nkwebkit_wtf and public_headers: 2 of 2 pass. On Windows the setgid line is inside #ifndef _WIN32 (Wtf.cpp:494-496). This run covers the perms::all check only.
  • check_conventions.py --base upstream/main passes.
  • pr_overlap.py --branch: 76 open PRs touch the same files. Two share exports:
    • #14932 is stacked through #14931, as this PR is.
    • #13486 (kyon-eth) adds no-parameter throwing stubs for deleteFile, fileExists, truncateFile and others. It is a 695-file branch (git diff --stat against main). Whichever of you lands second will need to resolve that.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5771174487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5771174487). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T15:39:42Z. **Review:** APPROVED --- @w4rc0n re-checked at `e4db024ffc`. `git range-diff` of my approved `d82592c45b` against this head shows one change to this PR's own patch, in the test, which is the fix for XairRrR's finding: - The directory-mode check masks with `perms::all` (`core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:511`). - Off Windows, the test sets setgid on its own temporary root first (`:495`). An inherited `S_ISGID` then no longer depends on the checkout's group. The library code is unchanged. **What I ran:** head `e4db024ffc` (it already contains `main` `b11c7bf84f`), Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`: - `nkwebkit_wtf` and `public_headers`: 2 of 2 pass. On Windows the setgid line is inside `#ifndef _WIN32` (`Wtf.cpp:494-496`). This run covers the `perms::all` check only. - `check_conventions.py --base upstream/main` passes. - `pr_overlap.py --branch`: 76 open PRs touch the same files. Two share exports: - #14932 is stacked through #14931, as this PR is. - #13486 (kyon-eth) adds no-parameter throwing stubs for `deleteFile`, `fileExists`, `truncateFile` and others. It is a 695-file branch (`git diff --stat` against `main`). Whichever of you lands second will need to resolve that.
BunnyFl commented 2026-11-05 03:18:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T03:18:07Z.

Review: APPROVED


@w4rc0n re-checked after the force-push. 10590b54e7 is a rebase of e4db024ffc, the head I approved: git range-diff shows no change to any code or test line. The only differences are hunk context and the dropped edit of the "Additional callable exports" count line in docs/dev/debt/libSceNKWebKit.md, which main has since reworded.

On 10590b54e7 merged onto main 0540ef0ef2 (Windows 11, WinLibs GCC 15.2.0, Release, nkwebkit_wtf_tests rebuilt), nkwebkit_wtf passed, 1 of 1. The new code is in a file this PR adds (core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp), and there is no main version to put back; neither of my earlier reviews had a behavioural negative control; I added one this time. Mutation check, on the same merge: with the new deleteFile accepting directories instead of refusing them (!= changed to == on the file-type test), nkwebkit_wtf aborts on a Require. check_conventions.py passes.

pr_overlap.py --branch: the rows with the same exports are your own #14932 (also stacked on #14931, which this one builds on). The other comparable rows share lines in Export.cpp, the export headers or the debt file but no exports; I haven't checked each of them against this PR. The tool couldn't compare about 50 more PRs, which conflict with main.

Approving again at 10590b54e7.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5779422282 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14949#pullrequestreview-5779422282). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-05T03:18:07Z. **Review:** APPROVED --- @w4rc0n re-checked after the force-push. `10590b54e7` is a rebase of `e4db024ffc`, the head I approved: `git range-diff` shows no change to any code or test line. The only differences are hunk context and the dropped edit of the "Additional callable exports" count line in `docs/dev/debt/libSceNKWebKit.md`, which `main` has since reworded. On `10590b54e7` merged onto `main` `0540ef0ef2` (Windows 11, WinLibs GCC 15.2.0, Release, `nkwebkit_wtf_tests` rebuilt), `nkwebkit_wtf` passed, 1 of 1. The new code is in a file this PR adds (`core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp`), and there is no `main` version to put back; neither of my earlier reviews had a behavioural negative control; I added one this time. Mutation check, on the same merge: with the new `deleteFile` accepting directories instead of refusing them (`!=` changed to `==` on the file-type test), `nkwebkit_wtf` aborts on a `Require`. `check_conventions.py` passes. `pr_overlap.py --branch`: the rows with the same exports are your own #14932 (also stacked on #14931, which this one builds on). The other comparable rows share lines in `Export.cpp`, the export headers or the debt file but no exports; I haven't checked each of them against this PR. The tool couldn't compare about 50 more PRs, which conflict with `main`. Approving again at `10590b54e7`. AI-assisted: yes (Claude Code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14949
No description provided.