Skip to content

test(libkernel): audit socket options bounds and length validation - #20957

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
slopgobblercobbler:slopgobblercobbler/pr-libkernel-socket-options-bounds
Nov 25, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
slopgobblercobbler:slopgobblercobbler/pr-libkernel-socket-options-bounds

Conversation

@slopgobblercobbler

@slopgobblercobbler slopgobblercobbler commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Add non-GTest standalone test GuestKernelSocketOptionsBounds.cpp verifying socket options SO_REUSEADDR, SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF bounds, length validation, and error precedence in accordance with docs/dev/debt/libkernel.md.

Tested

ctest --test-dir build -R guest_kernel_socket_options_bounds_tests

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 added the needs rebase Conflicts with main, rebase needed label Nov 15, 2026
@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-socket-options-bounds branch from 286d27c to 54ff78b Compare November 15, 2026 20:46
@github-actions

github-actions Bot commented Nov 15, 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 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 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 16790 core/libs/prx/libkernel/CMakeLists.txt
PR 18190 core/libs/prx/libkernel/CMakeLists.txt
PR 19181 core/libs/prx/libkernel/CMakeLists.txt
PR 24322 core/libs/prx/libkernel/CMakeLists.txt
PR 24910 core/libs/prx/libkernel/CMakeLists.txt
PR 24917 core/libs/prx/libkernel/CMakeLists.txt

@oneandonlydean

Copy link
Copy Markdown
Collaborator

The hosted Windows job fails on this head in guest_kernel_socket_options_bounds (exit 0xc0000409, 0.13 s): the test aborts on one of its Require lines and Require does not say which. The only other failure in the run is audio_out2_port_layouts, which is the red main being reverted, so this one is yours.

Please make Require print its line (a std::source_location default argument, as other tests in core/libs/tests do), find the failing check on Windows and either fix the expectation or say what the console does for that case.

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 54ff78b1b6:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_socket_options_bounds_tests built cleanly.
  • CTest (guest_kernel_socket_options_bounds):
    1/1 Test #5363: guest_kernel_socket_options_bounds ...   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Checked PR discussion where maintainer oneandonlydean explicitly requested updating Require in core/libs/tests/GuestKernelSocketOptionsBounds.cpp to print its line using std::source_location and diagnosing/fixing the Windows test failure.
    • Verified CMakeLists.txt placement of guest_kernel_socket_options_bounds_tests outside if(BUILD_TESTING) vs inside if(BUILD_TESTING) and test fragment conventions.
    • Audited GuestKernelSocketOptionsBounds.cpp for Require definition at lines 33-37 lacking std::source_location and diagnostic output.
    • Checked Windows socketpair_nid_postfix(AfUnix, SockDgram, ...) / pipe_nid_postfix / socket option behavior in TestSendBufferBoundsAndClamping and TestReceiveBufferBoundsAndClamping.
  • Concerns:
    • core/libs/tests/GuestKernelSocketOptionsBounds.cpp:33-37: Require(bool condition) still calls std::abort() without a std::source_location default parameter or line-number diagnostic output, and the failing Windows check reported by the maintainer (guest_kernel_socket_options_bounds exiting with 0xc0000409) has not been addressed.
    • core/libs/prx/libkernel/CMakeLists.txt:3221-3230: guest_kernel_socket_options_bounds_tests is added at the end of core/libs/prx/libkernel/CMakeLists.txt after endif() (outside if(BUILD_TESTING)), whereas libkernel tests belong inside if(BUILD_TESTING) (or a cmake/tests/*.cmake fragment included inside if(BUILD_TESTING)), breaking builds configured with -DBUILD_TESTING=OFF.

Requesting changes for the points above.

@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-socket-options-bounds branch from 54ff78b to 716bf8e Compare November 16, 2026 23:10

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 716bf8e3c9:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_kernel_socket_options_bounds_tests built cleanly.
  • CTest (guest_kernel_socket_options_bounds):
    1/1 Test #5345: guest_kernel_socket_options_bounds ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified core/libs/prx/libkernel/CMakeLists.txt: guest_kernel_socket_options_bounds_tests is correctly placed inside the if(BUILD_TESTING) block with proper dependencies and Windows unwind configuration.
    • Verified Require implementation in GuestKernelSocketOptionsBounds.cpp:36-41 now accepts std::source_location default parameter and prints failure location before aborting, addressing maintainer oneandonlydean's request.
    • Verified TestPrecedenceAndInputValidation, TestGetsockoptLengthAndPointerBounds, and TestReuseAddrBoundsAndSemantics correctly test SolSocket options, bounds, error precedence, and return codes (PosixEfault, PosixEinval, PosixEbadf, PosixEnotsock).
    • Verified TestKeepAliveBoundsAndSemantics handles platform-specific differences (Windows returning PosixEnoprotoopt for UDP keepalive vs Unix behavior) with clean #ifdef _WIN32 guards.
    • Verified TestReceiveBufferBoundsAndClamping and TestSendBufferBoundsAndClamping accurately test socket buffer boundaries (MaximumBuffer, MaximumReservation), clamping semantics, and error codes (PosixEinval, PosixEnobufs).
    • Verified TestListeningAndAcceptInheritance validates option inheritance from listening sockets to accepted stream sockets.

Looks Good To Me

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 17, 2026
@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-socket-options-bounds branch 2 times, most recently from a028060 to b5a91bb Compare November 18, 2026 09:58
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 18, 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 — no blocking findings

The added socket option bounds test and its CMake registration match the inspected libkernel behavior, but I did not run the test suite, so a formal approval is not justified.

What I ran

Reviewed head b5a91bbe76ba7920096f19352d98105801d3feb0 by reading the prepared diff and changed files, then inspecting the socket option implementation and an existing bounds test. No test command was run.

Results

Check Result Note
Changed lines inspected passed Both changed files read in full
Target test not run No test execution performed
Negative control not run No test execution performed

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The added test was not built or run. The changed files listed as reviewed in manifest.json were both read in full. Read for context: SocketOptions.cpp, Udp.cpp, GuestKernelSocketBufTimeoutBounds.cpp, and the review bundle documents. libkernel.md was searched but not read in full; other files excluded by the review bundle were not inspected.

To get this to a good state

Nothing is required. Optional: run ctest --test-dir build -R guest_kernel_socket_options_bounds_tests on the reviewed head and share the result.

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

Copy link
Copy Markdown
Collaborator

Build / windows fails to compile on b5a91bb. In core/libs/tests/GuestKernelSocketOptionsBounds.cpp, TestKeepAliveBoundsAndSemantics declares std::uint32_t len twice: the first one (around line 291, next to outputVal) sits inside #ifdef _WIN32, and line 316 declares it again in the same scope. Please rename or scope the Windows-only outputVal and len locals. The Linux build is clean, so this only shows on Windows.

The branch also conflicts with main in core/libs/prx/libkernel/CMakeLists.txt, so it needs a rebase.

The Windows-only expectations (ENOPROTOOPT for datagram SO_KEEPALIVE, ENOTSOCK for a pipe fd) depend on host WSA error mapping, so they will only be proven once the Windows job gets past the compile. Everything else I checked against SocketOptions.cpp matches.

@slopgobblercobbler

Copy link
Copy Markdown
Contributor Author

@oneandonlydean The PR has been updated:

  • Rebased cleanly onto latest upstream/main, resolving the CMake conflict in core/libs/prx/libkernel/CMakeLists.txt.
  • Scoped the Windows-specific locals (outputVal, winLen) in TestKeepAliveBoundsAndSemantics in core/libs/tests/GuestKernelSocketOptionsBounds.cpp to eliminate the duplicate len declaration on Windows.
  • Confirmed Require uses std::source_location for file and line diagnostics.
  • Verified 0 conventions findings via python tools/check_conventions.py --base upstream/main --head HEAD.

@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 — comments

The test adds broad socket option coverage, but it assumes an exact accepted-socket receive buffer value that the implementation does not guarantee across platforms.

What I ran

Reviewed head 5463362fbed939fc505fe0cb67a02b4ed1eba2ea. Read description.md, commits.md, manifest.json, diff.patch, the full changed test, and the changed CMake lines. Also inspected socket option implementation context in SocketOptions.cpp and Udp.cpp. No test or build command was run.

Results

Check Result Note
Source review passed Changed test and registration read
Test command not run Author reports a CTest run
Build not run No build performed

Findings

Blocking

None.

Non-blocking

  • core/libs/tests/GuestKernelSocketOptionsBounds.cpp:488: The test expects an accepted socket's receive buffer to equal exactly 16384. The implementation sets the native receive buffer, then stores the requested size capped at MaximumBuffer; host socket APIs may report a different effective size. Consider asserting the implementation's guest-visible state while allowing platform-specific native behavior, or avoiding this exact inheritance assertion where the host does not guarantee it.

Not verified

  • Did not run the author-reported CTest command or build the test.
  • files.json was not available through the reader; the manifest lists two changed files and both full texts were read. No excluded-file list could be confirmed.
  • No CI, other operating systems, or physical-console behavior was verified.

To get this to a good state

Nothing is required. The platform-sensitive assertion is optional feedback.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 21, 2026
# Conflicts:
#	core/libs/prx/libkernel/CMakeLists.txt
@slopgobblercobbler
slopgobblercobbler force-pushed the slopgobblercobbler/pr-libkernel-socket-options-bounds branch from 5463362 to d6e2ac5 Compare November 21, 2026 15:54
@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 — no blocking findings

Nothing blocks this change; the added socket option bounds test and its CMake registration are consistent with the inspected implementation, but the test was not run in this review.

What I ran

Reviewed head d6e2ac5ab548fd6a68541e6699d3826ab0ad4897 using repo_read.py to inspect the prepared diff and targeted source context. No test command was run.

Results

Check Result Note
Diff and changed files passed Both changed files read
Targeted implementation context passed Socket option handling and test registration inspected
CTest not run No shell available in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports running ctest --test-dir build -R guest_kernel_socket_options_bounds_tests; this review did not independently run it. No changed files were excluded: core/libs/prx/libkernel/CMakeLists.txt and core/libs/tests/GuestKernelSocketOptionsBounds.cpp were read. The prepared description, commit list, manifest and diff were inspected; repository context was read through repo_read.py.

To get this to a good state

Nothing is required. As an optional confidence check, run the focused CTest on the reviewed head.

@Helldiverr

Copy link
Copy Markdown
Contributor

Windows run of the current head, merged onto current main. The new test builds and passes 3/3, and the 19 related socket-option tests pass on main and on the merge. That answers the open question from oneandonlydean: on Windows, SO_KEEPALIVE on a datagram socket does fail with ENOPROTOOPT, and a pipe descriptor does fail with ENOTSOCK. On a negative control and 16 mutations of libkernel/Socket/src/SocketOptions.cpp and Udp.cpp, the new test catches 16 and misses one equivalent mutation. Every catch but one is also caught by an existing test. The exception is the Windows-only SO_KEEPALIVE result, which no debt entry records. Before merge, the test registration needs to move to a CMake fragment, the Windows SO_KEEPALIVE divergence needs a debt entry, and the Tested section needs an OS and a pattern that selects the test.

Existing runs:

  • the author, slopgobblercobbler: Tested gives ctest --test-dir build -R guest_kernel_socket_options_bounds_tests, with no OS. That pattern is the executable name, so it selects nothing; here ctest prints "No tests were found!!!" and exits 0.
  • oneandonlydean reported that the hosted Windows CI job failed on earlier heads, first in this test and then at compile time. The second comment says the Windows-only expectations would only be proven once that job got past the compile. Those are CI jobs, not runs on a reviewer's machine.
  • PrivacyOnion ran 54ff78b1b6 and 716bf8e3c9 on Linux (Ubuntu 24.04, GCC 13.3), where the test passed, and approved 716bf8e3c9.
  • MarcZX10 commented on b5a91bbe76, 5463362fbe and d6e2ac5ab5 without running anything.

No Windows run at this head before this one.

What this run adds.
A Windows run of d6e2ac5ab5 merged onto main ca01126e05, three times. It runs the 19 related libkernel tests on main, and the same 19 plus the new test on the merge. The related tests are the ones whose sources call setsockopt, getsockopt or their _ and sceNet forms on the options this test covers. guest_sendmsg_control is one of them but is not registered on Windows. After that, a negative control and 16 mutations show which test catches each one. check_conventions.py --base and debt_fold.py --check were also run.

Code.

  • Registration (CONTRIBUTING.md:73 on main ca01126e05): "A new libc or libkernel test executable and its tests are registered in core/libs/prx/libc/tests/cmake/<executable>.cmake or core/libs/prx/libkernel/tests/cmake/<executable>.cmake. That library's CMakeLists.txt includes the fragments in sorted order after its own registrations, so a fragment can use what CMakeLists.txt defines but nothing another fragment defines. Tests already registered in CMakeLists.txt stay there." The PR adds the new executable to core/libs/prx/libkernel/CMakeLists.txt (head lines 2124-2133). The rule came in with a61eda1dd6, which is in the PR's base. check_conventions.py does not report it. The fragments already in core/libs/prx/libkernel/tests/cmake/ on main show the shape: the same lines, in a file named after the executable.
  • SO_KEEPALIVE on a datagram socket (head lines 289-299 and 330-339): under #ifdef _WIN32 the test requires getsockopt and setsockopt to fail with ENOPROTOOPT, and on other hosts it requires them to work. That is Winsock refusing the option at the host call (SocketOptions.cpp:275 and 343 on main ca01126e05). FreeBSD 11.4's sosetopt takes SO_KEEPALIVE in the same case group as SO_BROADCAST and sets the bit on any socket type (sys/kern/uipc_socket.c L2554-L2577 at 8c639945a4, the commit the debt file cites). docs/dev/debt/libkernel.md on main records the same Winsock refusal for SO_LINGER on a datagram socket (line 330) and SO_BROADCAST on a stream socket (line 331), but has nothing for SO_KEEPALIVE. Line 318 says only that SO_KEEPALIVE acts on the host socket. AGENTS.md: "Known gaps go in docs/dev/debt/<library>.md, added, changed or removed through a fragment in docs/dev/debt/changes/". A fragment shaped like line 331 would record it. The keepalive-dgram-accepted row below shows that this check is the only thing that fails if main ever matches FreeBSD here, so the test now pins the divergence.
  • Tested (CONTRIBUTING.md:83 on main ca01126e05): "Run the tests before opening the pull request and describe what was tested (OS, title or homebrew)." The test is named guest_kernel_socket_options_bounds (head CMakeLists.txt:2128), so -R guest_kernel_socket_options_bounds selects it.
  • The accepted-socket SO_RCVBUF of 16384 at head line 488, which MarcZX10 flagged as host-dependent on 5463362fbe, reads guest state the listener passes on (Udp.cpp:2062 on main), not the host's reported size. It passes on Windows, and the accept-rcvbuf-not-inherited row below fails at that line.
  • Overlap: guest_socket_options and guest_kernel_socket_buf_timeout_bounds already catch the buffer, boolean, kept-flag and length mutations. guest_kernel_socket_broadcast_debug_route_bounds and guest_net_tcp_options catch the argument-order ones. Apart from the Windows SO_KEEPALIVE result, I found nothing that only this test checks.
  • Require (lines 36-41) prints the failing line. All failing lines in the table below came from it.

Negative control and mutation.
Each mutation is applied alone at the merge, and then the 20 tests are rebuilt and run. Line numbers are in main ca01126e05, which the PR does not change in these files. The new-test column gives the line it stopped at.

Mutation Change New test Other tests that fail
negative control a buffer size of 0 is accepted (SocketOptions.cpp:258, < 1 to < 0) fails, line 375 guest_kernel_socket_buf_timeout_bounds, guest_socket_options
enobufs-removed no ENOBUFS above 5592405 (SocketOptions.cpp:267) fails, line 381 guest_kernel_socket_buf_timeout_bounds, guest_socket_options
enobufs-at-limit ENOBUFS at exactly 5592405 (SocketOptions.cpp:267, > to >=) fails, line 60 (called from 399) guest_kernel_socket_buf_timeout_bounds, guest_socket_options
clamp-removed no 524288 limit on the kept size (SocketOptions.cpp:270) fails, line 397 guest_kernel_socket_buf_timeout_bounds, guest_socket_options
inet-dgram-rcvbuf-default UDP SO_RCVBUF default 41600 (SocketOptions.cpp:140) fails, line 352 guest_kernel_socket_buf_timeout_bounds, guest_socket_options
inet-dgram-sndbuf-default UDP SO_SNDBUF default 9200 (SocketOptions.cpp:139) fails, line 413 guest_kernel_socket_buf_timeout_bounds, guest_socket_options, guest_socket_pair
unix-dgram-sndbuf-default Unix datagram SO_SNDBUF default 4096 (SocketOptions.cpp:136) fails, line 430 guest_kernel_socket_buf_timeout_bounds, guest_socket_options, guest_socket_pair
boolean-reads-one a set boolean option reads back as 1, not its bit (SocketOptions.cpp:344) fails, line 302 guest_socket_options, guest_kernel_socket_broadcast_debug_route_bounds
kept-flag-reads-one a set kept flag reads back as 1, not its bit (SocketOptions.cpp:352) fails, line 242 guest_sce_net_reuseport_ipv4, guest_sce_net_reuseport_ipv6, guest_socket_options
short-length-accepted boolean and buffer options take a length under 4 (SocketOptions.cpp:254) fails, line 127 guest_kernel_socket_buf_timeout_bounds, guest_socket_options, guest_udp, guest_kernel_socket_broadcast_debug_route_bounds
copy-ignores-length getsockopt writes the whole value whatever the length (SocketOptions.cpp:175) fails, line 185 guest_kernel_socket_buf_timeout_bounds, guest_socket_options, guest_socket_stream_options, guest_socket_timeouts, guest_kernel_socket_broadcast_debug_route_bounds
copy-null-output the copy no longer treats a null value as length 0 (SocketOptions.cpp:175) passes none; equivalent here, as getsockopt already passes length 0 for a null value (Udp.cpp:1776-1777)
set-efault-after-lookup setsockopt checks the null value after the descriptor (Udp.cpp:1752) fails, line 104 guest_net_tcp_options, guest_kernel_socket_buf_timeout_bounds, guest_socket_options, guest_kernel_socket_broadcast_debug_route_bounds
set-einval-after-lookup setsockopt checks a negative length after the descriptor (Udp.cpp:1753) fails, line 109 guest_kernel_socket_buf_timeout_bounds, guest_kernel_socket_broadcast_debug_route_bounds
get-null-length-skipped getsockopt drops the length copy-in and copy-out (Udp.cpp:1777-1778) fails, line 165 12 others, including guest_socket_options, guest_udp and guest_underscore_entries
accept-rcvbuf-not-inherited an accepted socket does not take the listener's SO_RCVBUF (Udp.cpp:2062) fails, line 488 guest_socket_options
keepalive-dgram-accepted SO_KEEPALIVE on a UDP socket is accepted as on FreeBSD (SocketOptions.cpp:275 and 343) fails, line 293 none

Tests.

Run Commit Result
19 related tests, main ca01126e05 19/19 passed
20 tests, merge, run 1 8be3535ffa 20/20 passed
20 tests, merge, run 2 8be3535ffa 20/20 passed
20 tests, merge, run 3 8be3535ffa 20/20 passed
author's -R guest_kernel_socket_options_bounds_tests 8be3535ffa no tests found, exit 0
check_conventions.py --base 8be3535ffa passed
debt_fold.py --check 8be3535ffa exit 0

Neither build logged a compiler warning.

Host:

  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits: head d6e2ac5ab5, merged onto main ca01126e05 as 8be3535ffa

AI-assisted: yes

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 24, 2026
# Conflicts:
#	core/libs/prx/libkernel/CMakeLists.txt
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 25, 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 — changes requested

Changes are required before merge: correct the expected errno for unsupported socket options so the new test matches the implementation.

What I ran

Reviewed head 1e21b49c9b82217d529772b18fd9a695a9a86d29. Read the prepared description, commits, diff, manifest, and both changed files; inspected socket option handling and the existing socket bounds test through repo_read.py. No build or tests were run.

Results

Check Result Note
Changed-file review failed Unsupported-option errno assertions conflict with implementation
CTest not run No test execution in this review

Findings

Blocking

  • core/libs/tests/GuestKernelSocketOptionsBounds.cpp:124 and core/libs/tests/GuestKernelSocketOptionsBounds.cpp:179: The test expects EINVAL for unknown option 12345 at SOL_SOCKET. The socket option handlers return ENOPROTOOPT for unknown options; the test uses the same incorrect expectation for both setsockopt aliases at lines 124–125 and both getsockopt aliases at lines 179–180. Update these expected errors to PosixEnoprotoopt so the test checks the implemented behavior.

Non-blocking

None.

Not verified

The CTest target was not built or run, so other platform-specific assertions and the author's reported run were not verified. All changed files listed in the manifest were read; files.json was unavailable, so excluded-file details could not be checked.

To get this to a good state

Correct the four unsupported-option errno expectations, then build and run guest_kernel_socket_options_bounds_tests on the intended platforms.

@oneandonlydean
oneandonlydean dismissed MarcZX10’s stale review November 25, 2026 13:55

Checked this against the source at 1e21b49. Lines 124-125 and 179-180 pass an unknown level (12345 and 54321) with a valid option, not an unknown option at SOL_SOCKET. setsockopt and getsockopt in core/libs/prx/libkernel/Socket/src/Udp.cpp (lines 1775 and 1806) send every level other than SOL_SOCKET, IPPROTO_IP, IPPROTO_TCP and IPPROTO_IPV6 to UnsupportedLevelError, which returns EINVAL here (ENOPROTOOPT only for UDP at level 17 or an IP socket at level 0). So PosixEinval is the right expectation, and the suggested ENOPROTOOPT would make the test fail.

@oneandonlydean
oneandonlydean merged commit 4954659 into boykopovar:main Nov 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants