Repository navigation
test(libkernel): audit getpeername unconnected and listening socket bounds - #17437
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a3db4aaea3:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_kernel_getpeername_flags_testsbuilt cleanly. - CTest (
guest_kernel_getpeername_flags):1/1 Test #4175: guest_kernel_getpeername_flags ...Subprocess aborted***Exception: 0.46 sec 0% tests passed, 1 tests failed out of 1The following tests FAILED: - Note: the AI-assisted checkbox can stay.
Requesting changes for the points above.
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, Vulkan hidden for this CPU-only run. The Tests run (from the log): Fails in 3 of 3 runs: I've only quoted the output here and haven't traced the cause. AI-assisted: yes. |
|
@slopgobblercobbler, the test fails as written. Line 39 expects EINVAL (22) when the length pointer is null, but getpeername_nid_postfix in Udp.cpp copies the length in first and returns EFAULT (14), which matches FreeBSD, and JJenkx's Windows run shows the same failure ("line 39, errno 14", 3 of 3). The hosted windows check is red on this head too. Beyond that, most of the file repeats main: a fresh socket returning 57 is in GuestTcp.cpp, GuestSocketPortZero.cpp, GuestUdp.cpp and GuestSocketPair.cpp, and the truncation, oversized length and null address cases are in GuestTcp.cpp and GuestSocketPortZero.cpp. The test never exercises those cases, so the title overstates it, and nullSize is declared and never used. Could you drop the new file and its CMake entry, and if you want to keep the length 0 and bound plus listening socket returning 57 checks, add them to GuestTcp.cpp next to the existing 57 check? |
|
Windows check of head Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release,
AI-assisted: yes. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The reviewed change adds a focused getpeername guest test; I found no verified blocking defect, but did not run the test suite.
What I ran
Reviewed head a3db4aaea3e96cfa2808df285309981878af5bc7 using repo_read.py tools to read the prepared review documents and changed source. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Changed source review | passed | Both changed files read |
| Build and tests | not run | No test execution available |
Findings
Blocking
None.
Non-blocking
core/libs/tests/GuestKernelGetpeernameFlags.cpp:35passes a zero address length togetpeernameon an unconnected socket and expectsNotConnected. Since that error can occur before address-length handling, this case does not establish the claimed address-length-bound behavior. Exercise an appropriate connected socket case to verify the length handling directly.
Not verified
No build or CTest run was performed. Both changed files listed in the manifest were read; no changed files were excluded. Runtime behavior on Windows was not verified.
To get this to a good state
Nothing is required. The address-length test improvement is optional.
a3db4aa to
6691f2b
Compare
|
@oneandonlydean @PrivacyOnion @JJenkx @gabichuuuuu
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 6691f2ba39:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_tcp_testsbuilt cleanly. - CTest (
guest_tcp):1/1 Test #5860: guest_tcp ........................ Passed 0.61 sec 100% tests passed, 0 tests failed out of 1 - Code reading:
- Verified that getpeername on unconnected socket with size = 0 returns -1 and sets errno to ENOTCONN (57), as FreeBSD/PS5 checks connection state before copying out the address in core/libs/tests/GuestTcp.cpp:275-276.
- Verified that getpeername on listening socket (listener) with size = address.size() returns -1 and sets errno to ENOTCONN (57) in core/libs/tests/GuestTcp.cpp:277-278.
- Verified that the added test assertions properly clean up file descriptors ({unconnected, accepted, client, listener}) via close_nid_postfix at line 280.
- Verified that no comments were added to code, adhering to AGENTS.md conventions, and check_conventions.py passed mechanically.
- Confirmed maintainer oneandonlydean's explicit request to drop the standalone test file and fold the size = 0 and listening socket ENOTCONN checks into GuestTcp.cpp was accurately and cleanly followed.
Looks Good To Me
What
Audit
getpeernamebehavior on unconnected and listening TCP sockets incore/libs/tests/GuestTcp.cpp. Verifies returningENOTCONN(57) forsize = 0on unconnected sockets and for listening sockets. Standalone test executable removed per maintainer review.Tested
ctest --test-dir build -R guest_kernel_tcp_testspython tools/check_conventions.py --base upstream/main --head HEAD(0 findings)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)