Skip to content

test(libkernel): audit pathconf and fpathconf parameter boundaries and error handling - #17521

Closed
slopgobblercobbler wants to merge 1 commit into
boykopovar:mainfrom
slopgobblercobbler:slopgobblercobbler/pr-libkernel-pathconf-bounds
Closed

slopgobblercobbler wants to merge 1 commit into
boykopovar:mainfrom
slopgobblercobbler:slopgobblercobbler/pr-libkernel-pathconf-bounds

Conversation

@slopgobblercobbler

@slopgobblercobbler slopgobblercobbler commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Authors standalone guest unit test guest_kernel_pathconf_bounds_tests auditing pathconf, fpathconf, and _fpathconf configuration parameter validation, invalid name parameter returning PosixEinval (22), invalid/closed file descriptor returning PosixEbadf (9), null path returning PosixEfault (14), non-existent/empty path returning PosixEnoent (2), pipe buffer and asynchronous IO readbacks, and valid limit readbacks (_PC_NAME_MAX 255, _PC_PATH_MAX 1024, _PC_PIPE_BUF 512, _PC_LINK_MAX 32767, _PC_FILESIZEBITS 64).

Tested

Conventions check (python tools/check_conventions.py --base upstream/main passed with 0 errors).

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4563 core/libs/prx/libkernel/CMakeLists.txt
PR 6149 core/libs/prx/libkernel/CMakeLists.txt
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
PR 8041 core/libs/prx/libkernel/CMakeLists.txt
PR 9156 core/libs/prx/libkernel/CMakeLists.txt
PR 9293 core/libs/prx/libkernel/CMakeLists.txt
PR 9297 core/libs/prx/libkernel/CMakeLists.txt
PR 9302 core/libs/prx/libkernel/CMakeLists.txt
PR 9383 core/libs/prx/libkernel/CMakeLists.txt
PR 9389 core/libs/prx/libkernel/CMakeLists.txt
PR 9557 core/libs/prx/libkernel/CMakeLists.txt
PR 9566 core/libs/prx/libkernel/CMakeLists.txt
PR 9938 core/libs/prx/libkernel/CMakeLists.txt
PR 11896 core/libs/prx/libkernel/CMakeLists.txt
PR 12544 core/libs/prx/libkernel/CMakeLists.txt
PR 12682 core/libs/prx/libkernel/CMakeLists.txt
PR 12688 core/libs/prx/libkernel/CMakeLists.txt
PR 12700 core/libs/prx/libkernel/CMakeLists.txt
PR 12965 core/libs/prx/libkernel/CMakeLists.txt
PR 16372 core/libs/prx/libkernel/CMakeLists.txt
PR 16790 core/libs/prx/libkernel/CMakeLists.txt
PR 18112 core/libs/prx/libkernel/CMakeLists.txt
PR 18190 core/libs/prx/libkernel/CMakeLists.txt
PR 18293 core/libs/prx/libkernel/CMakeLists.txt
PR 19181 core/libs/prx/libkernel/CMakeLists.txt
PR 22391 core/libs/prx/libkernel/CMakeLists.txt
PR 25949 core/libs/prx/libkernel/CMakeLists.txt
PR 26174 core/libs/prx/libkernel/CMakeLists.txt
PR 26206 core/libs/prx/libkernel/CMakeLists.txt
PR 27563 core/libs/prx/libkernel/CMakeLists.txt
PR 27717 core/libs/prx/libkernel/CMakeLists.txt
PR 27813 core/libs/prx/libkernel/CMakeLists.txt
PR 27864 core/libs/prx/libkernel/CMakeLists.txt
PR 28043 core/libs/prx/libkernel/CMakeLists.txt
PR 28045 core/libs/prx/libkernel/CMakeLists.txt
PR 28051 core/libs/prx/libkernel/CMakeLists.txt
PR 28253 core/libs/prx/libkernel/CMakeLists.txt
PR 28299 core/libs/prx/libkernel/CMakeLists.txt
PR 28323 core/libs/prx/libkernel/CMakeLists.txt
PR 28434 core/libs/prx/libkernel/CMakeLists.txt
PR 28702 core/libs/prx/libkernel/CMakeLists.txt

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head c228897575, merged onto main 0bae53facd (947394692b, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, Vulkan hidden for this CPU-only run. The linux check is skipped on this PR.

The PR does not build on Windows (MinGW GCC 15.2):

core/libs/tests/GuestKernelPathconfBounds.cpp:30:16: error: conflicting declaration of C function 'void AddPathAlias_nid_no_patch(const char*, const char*)'

I've only quoted the output here and haven't traced the cause.

AI-assisted: yes.

@DonRyuzaki

Copy link
Copy Markdown
Contributor

I reproduced the Windows build failure on the exact, clean PR head c2288975756ab10634191fe00d0b1e4022a222ff (Windows 11, WinLibs GCC 15.2 UCRT, Release, two compiler jobs). Credit to @JJenkx for first reporting the compiler error. I traced it further with temporary local test-only edits; these edits are not in the PR and I restored the clean worktree afterward.

  1. GuestKernelPathconfBounds.cpp:30 redeclares AddPathAlias_nid_no_patch with APS5_VABI (sysv_abi on MinGW), while libc/include/General.hpp:50 already declares the same helper with the host ABI. Removing the duplicate declaration gets past compilation.
  2. Linking then fails with undefined pathconf_nid_postfix: the test links libkernel and libc, but pathconf_nid_postfix is exported by libkernel_sys. Linking libkernel_sys instead gets past the linker.
  3. The test then aborts at its first success case. With diagnostic output, pathconf returned the expected 255 but errno was 2; successful POSIX calls need not clear errno. Removing the two errno == 0 assertions after successful calls lets the registered guest_kernel_pathconf_bounds CTest pass 3/3 on Windows (0.05, 0.02, 0.02 s).

The unchanged PR head does not build on Windows; the 3/3 pass applies only to this diagnostic variant. I did not test a title or PS5 hardware. AI-assisted: yes (Codex).

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head c228897575, merged onto main 28237a8567 (clean merge, built on its own).

Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release, BUILD_TESTING=ON, Python 3.15.

  • The merged tree does not build: core/libs/tests/GuestKernelPathconfBounds.cpp:30:16: error: conflicting declaration of C function 'void AddPathAlias_nid_no_patch(const char*, const char*)'.
  • The test declares AddPathAlias_nid_no_patch itself with a signature that no longer matches the one on current main.
  • Tests not run, since the test does not compile.

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@slopgobblercobbler pathconf_nid_postfix is defined in libkernel_sys (prx/libkernel_sys/Export.cpp, declared in libkernel_sys/include/Api.hpp), but guest_kernel_pathconf_bounds_tests links only libkernel and libc, so I expect it to fail at link time. It also declares the function itself instead of including that header.
Main already checks most of this in CheckPathconf in GuestKernelSys.cpp: the NAME_MAX 255 and PATH_MAX 1024 values, other configuration names, and an unreadable path. If the new cases (nonexistent path gives ENOENT, unknown name gives EINVAL) are not covered there, please add them to that function instead of a new executable. If you keep a separate test, link libkernel_sys and include its header.

@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-pathconf-bounds branch from c228897 to f98cc80 Compare November 16, 2026 23:34
@slopgobblercobbler slopgobblercobbler changed the title test(libkernel): audit pathconf path parameter boundaries and error handling test(libkernel): audit pathconf and fpathconf parameter boundaries and error handling Nov 16, 2026
@slopgobblercobbler

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto upstream/main (f98cc80ef1f):

  • Implemented pure guest scope standalone test guest_kernel_pathconf_bounds_tests without host filesystem APIs (std::filesystem).
  • Included prx/libkernel_sys/include/Api.hpp and linked libkernel libkernel_sys libc.
  • Added comprehensive coverage for pathconf, fpathconf, and _fpathconf parameter boundaries: null path (EFAULT 14), non-existent/empty path (ENOENT 2), invalid name (EINVAL 22), invalid/closed file descriptor (EBADF 9), pipe buffer and asynchronous IO readbacks, and valid limit readbacks (_PC_NAME_MAX 255, _PC_PATH_MAX 1024, _PC_PIPE_BUF 512, etc.).
  • Registered in core/libs/prx/libkernel/CMakeLists.txt with configure_windows_unwind.
  • Verified python tools/check_conventions.py --base upstream/main passed cleanly with 0 errors.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 19, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The test registration and assertions are consistent with the implementation at head f98cc80ef1fde9d1457e852e7121969e1bcc9393; no blocking defect was verified.

What I ran

Read the prepared diff and both changed files at the pinned head. Also read the pathconf implementation and existing pathconf test coverage. No build or test command was run.

Results

Check Result Note
Changed file review passed Both changed files read
Targeted implementation review passed Pathconf behavior checked
Build and tests not run No execution performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

Build and runtime behavior were not verified. Both files listed as reviewed in the manifest were read: core/libs/prx/libkernel/CMakeLists.txt and core/libs/tests/GuestKernelPathconfBounds.cpp. No excluded changed files were listed.

To get this to a good state

Nothing is required.

@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-pathconf-bounds branch from f98cc80 to 1439bc3 Compare November 20, 2026 20:13
@slopgobblercobbler

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto latest upstream/main (1439bc31bd7):

  • Resolved conflict in core/libs/prx/libkernel/CMakeLists.txt preserving both guest_kernel_mutexattr_protocol_bounds_tests and guest_kernel_pathconf_bounds_tests.
  • Verified python tools/check_conventions.py --base upstream/main --head HEAD passes with 0 findings.
  • PR is mergeable and ready for review.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 20, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this test-only change; the review supports merging, but the new test was not run here.

What I ran

Reviewed head 1439bc31bd7a570f71d798aef812ae4b6b28dc03 against the prepared diff. Used repo_read.py to read both changed files in full and targeted existing implementation and test context. No build or test command was run; no merged-preview check was performed. The PR description reports a conventions check, which I did not run.

Results

Check Result Note
Diff and changed files passed Both changed files read in full
Targeted source context passed Existing implementation and related tests read
Build and new test not run No execution environment used

Findings

Blocking

None.

Non-blocking

None.

Not verified

The new test was not built or executed, so its runtime behavior and platform-specific results are unverified. No files were excluded from the prepared review bundle; both changed files listed as reviewed in the manifest were read in full. Related source files were read only in targeted ranges.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 21, 2026
@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-pathconf-bounds branch from 1439bc3 to 0faa9bd Compare November 21, 2026 16:00
@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-pathconf-bounds branch from 0faa9bd to 5e4d0d2 Compare November 21, 2026 16:02
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 21, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

The change was reviewed at the supplied head, but the review folder and pinned repository reader are unavailable in this environment, so the code and changed-file list could not be verified.

What I ran

No reader commands were run; this environment exposes no shell or reader tool.

Results

Check Result Note
Review inputs not run Inputs unavailable
Changed code audit not run No files read

Findings

Blocking

None verified.

Non-blocking

Unable to assess the change without the prepared review files and reader access.

Not verified

The PR description, commits, diff, manifest, changed files, repository context, and any tests were not read or run.

To get this to a good state

Provide the review inputs and reader access so the change can be reviewed against its pinned head.

@ycbuzi

ycbuzi commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 5e4d0d2d1d merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 4 tests failed out of 6714; 99% tests passed, 2 tests failed out of 6714. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 6714; 100% tests passed, 0 tests failed out of 6714. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing because main already covers these checks in core/libs/tests/GuestKernelSys.cpp: CheckPathconf has the values, invalid names, and the null, empty and missing path errors, and the fpathconf helpers cover both entry points on files, directories and pipes, plus bad and closed descriptors. The additions here (name 999, more bad descriptor numbers, closed pipe ends, a create and unlink sequence) go through the same code paths. Thank you for the work on it, and please reopen if there is a case that reaches behaviour main does not test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants