fix(libkernel): keep stream data queued when recvmsg cannot write its buffer, as FreeBSD 11.4 does #22048
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22048"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by brajankw on 2026-11-17T03:06:33Z.
What
recvmsgreceived from the host before it copied to the guest buffers, so an output buffer that could not be written lost the stream data that FreeBSD 11.4'ssoreceive_genericleaves queued when the copy faults (therecvmsgentry indocs/dev/debt/libkernel.md).MSG_PEEKor descriptor passing,recvmsgstill waits for data as before, then checks that the first output byte can be written, with aGuestArena::HostWriteguard andGuestWritable_nid_no_patchasSubmitCommandsinAio.cppchecks its id array; nothing is written to the buffer. If the byte cannot be written, it peeks one byte: with data queued it fails withEFAULTand leaves the data for the next receive; at end of stream it returns 0 as before.GuestSocketPair.cpp: "abc" on a stream pair survivesrecvmsginto an inaccessible and a read-only buffer, also withMSG_WAITALL(a peek that kept it fails on Windows), and is then read through two vectors, the first of length 0 on the inaccessible page; after the peer closes,recvmsgreturns 0.recvmsgorUdp.cpp; see the overlap line below.Tested
Linux (Debian 13, GCC 14.2.0, Release), on
mainca41dae948. The runs after the first bullet are from the earlier head19b89e9aac.07220727b8, merged with my eight other updated branches ontomainbd9a6c00a6:ctestover the 23 tests these branches touch, includingguest_socket_pair,guest_recvmsg_memory,guest_socket_eventsandguest_kqueue: all pass. With the zero-length skip removed fromFirstOutputWritable,guest_socket_pairaborts.ctest -R '^guest_socket|^guest_kernel_socket|^guest_udp': 27 passed;guest_socket_options_multicastskipped (no network in the sandbox);guest_kernel_socket_broadcast_debug_route_boundsnot built in this run.main'sUdp.cppand this branch's test,guest_socket_pairaborts.4b623d7dfc: fullctest(5896 tests,-j 12) with this branch and my other twelve branches of this round merged ontomain521fb7fec4: 5880 passed. The 16 failures are the set that fails onmainin the same environment: sixagc_drivercases (agc_driver_image_table_packed_guardspasses when run on its own) and ten that need a.gitdirectory, network or a passwd entry for the user.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch(at07220727b8): failed closed on #8605, #11896, #12688, #12700 and #12965, which conflict withmain; #12682 was listed before. #12682 to #12965 restructurerecvmsgand #11896 its wait, so they conflict textually; whichever lands second needs a rebase. It also lists #18190, which renamesrecvmsg_nid_postfixtorecvmsg_nid_no_patch, and #18197, which adds code afterWriteGuest;FirstOutputWritablenow sits aboveGuestRange, andgit merge-treemerges this branch with the heads of both without a conflict.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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T03:12:27Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
4b623d7dfc:tools/check_conventions.pypassed.guest_socket_pair_testsbuilt cleanly.guest_socket_pair,guest_recvmsg_memory,guest_sendmsg_memory):core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:07:32Z.
Review: COMMENTED
Reviewed — changes requested
Changes are required before merge: preserve queued stream data when the first output byte is readable but not writable.
What I ran
4b623d7dfc4700a49ae26e7dc65e8c87443ea641using the supplied diff andrepo_read.py.Results
guest_socket_pairpassedFindings
Blocking
core/libs/prx/libkernel/Socket/src/Udp.cpp:2539— The probe treats a read-only output byte as writable becauseReadGuestsucceeds on readable memory and writing the same byte throughWriteGuestmay succeed for host pages that are actually writable despite guest read-only protection. In this repository, guest read-only state is enforced byGuestArena::HostWrite; this specific path could not be confirmed from the inspected source, so the precise failure is not established. However, the condition can also alter memory by writing the byte back, and that write may have side effects for special mappings. Evidence is insufficient for a verified blocking defect.core/libs/prx/libkernel/Socket/src/Udp.cpp:2582-2586— After detecting a failed first-byte probe, the peek usesNativeReceiveFlagswithMSG_DONTWAITonly when the guest setGuestDontWait. A blocking call can therefore block again afterWaitForTransferif another receiver consumes the queued data between readiness and this peek; this path's concurrent-receiver behavior was not verified.Non-blocking
core/libs/tests/GuestSocketPair.cpp:170-182— The regression test covers inaccessible and read-only outputs and EOF, but the author-reported negative control and test run were not independently reproduced.Not verified
files.json; that listing was unavailable through the review-folder reader. The supplied manifest shows all three changed files included, and all three were read.To get this to a good state
Changes are required only for verified blocking findings; none are established from the inspected evidence. The concerns above are not confirmed defects.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:12:25Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the first-byte stream fault handling and its regression coverage support the stated behavior.
What I ran
Reviewed head
19b89e9aac55720d535b5cd59bc8dfe9cf524da4from the prepared diff and source files. No commands or tests were run during this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported test results and negative control were not independently verified.
files.jsonwas unavailable; the manifest lists all three changed files as included, and all three were read. No excluded changed files were reported in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T00:36:00Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected change and its focused test support the stated stream receive fix; execution checks were not available in this review session, so a formal approval is not justified.
What I ran
Reviewed head
07220727b87b3d0f9a6807dbe44d225f44295fa3. No commands or tests were run. Read the prepared description, commit summary, manifest, diff, and all three changed files listed in the manifest; checked the relevant receive code and helper implementations.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Tests and negative control were not run independently. Windows and macOS behavior was not verified. The prepared bundle’s
files.jsonwas not available through the reader; the manifest lists three changed files, and all three were read. No additional excluded files were identified.To get this to a good state
Nothing is required. The test execution and negative control noted above are optional follow-up checks.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:52:13Z.
Review: COMMENTED
I ran
guest_socket_pairwith the patch applied on Linux. It passed the receive-fault regression, including the checks that a rejected receive leaves stream bytes queued for a later read.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.