Repository navigation
test(libkernel): audit socket options bounds and length validation - #20957
Conversation
286d27c to
54ff78b
Compare
|
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.
|
|
The hosted Windows job fails on this head in Please make |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 54ff78b1b6:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_kernel_socket_options_bounds_testsbuilt 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 callsstd::abort()without astd::source_locationdefault parameter or line-number diagnostic output, and the failing Windows check reported by the maintainer (guest_kernel_socket_options_boundsexiting with0xc0000409) has not been addressed. - core/libs/prx/libkernel/CMakeLists.txt:3221-3230:
guest_kernel_socket_options_bounds_testsis added at the end ofcore/libs/prx/libkernel/CMakeLists.txtafterendif()(outsideif(BUILD_TESTING)), whereaslibkerneltests belong insideif(BUILD_TESTING)(or acmake/tests/*.cmakefragment included insideif(BUILD_TESTING)), breaking builds configured with-DBUILD_TESTING=OFF.
- core/libs/tests/GuestKernelSocketOptionsBounds.cpp:33-37:
Requesting changes for the points above.
54ff78b to
716bf8e
Compare
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 716bf8e3c9:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_kernel_socket_options_bounds_testsbuilt 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
a028060 to
b5a91bb
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
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. |
b5a91bb to
5463362
Compare
|
@oneandonlydean The PR has been updated:
|
MarcZX10
left a comment
There was a problem hiding this comment.
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 exactly16384. The implementation sets the native receive buffer, then stores the requested size capped atMaximumBuffer; 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.jsonwas 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.
# Conflicts: # core/libs/prx/libkernel/CMakeLists.txt
5463362 to
d6e2ac5
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
Windows run of the current head, merged onto current Existing runs:
No Windows run at this head before this one. What this run adds. Code.
Negative control and mutation.
Tests.
Neither build logged a compiler warning. Host:
AI-assisted: yes |
# Conflicts: # core/libs/prx/libkernel/CMakeLists.txt
MarcZX10
left a comment
There was a problem hiding this comment.
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:124andcore/libs/tests/GuestKernelSocketOptionsBounds.cpp:179: The test expectsEINVALfor unknown option12345atSOL_SOCKET. The socket option handlers returnENOPROTOOPTfor unknown options; the test uses the same incorrect expectation for bothsetsockoptaliases at lines 124–125 and bothgetsockoptaliases at lines 179–180. Update these expected errors toPosixEnoprotooptso 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.
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.
What
Add non-GTest standalone test
GuestKernelSocketOptionsBounds.cppverifying socket optionsSO_REUSEADDR,SO_KEEPALIVE,SO_RCVBUF,SO_SNDBUFbounds, 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)