fix(libkernel): report a reset stream socket as hung up and keep POLLOUT on a half-closed one as measured on a PS5 #11247
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11247"
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 orezraey on 2026-10-25T22:33:31Z.
What
pollon a guest stream socket now reports a reset connection as a retail PS5 (firmware 13.60) does:POLLHUPplus the requested read bits, neverPOLLERRand neverPOLLOUT. On Windows it also keepsPOLLOUTfor a socket whose peer closed while it can still send. Measured with a homebrew probe from a payload process, over loopback TCP, with events 0,POLLINandPOLLIN|POLLOUT; the source and console log are in this gist (ppollhup).On the console:
POLLHUP).recvreturns 0.SO_LINGER{1, 0}): 0x10, 0x11 and 0x11, with noPOLLERR. The firstrecvfails withECONNRESET(54).FreeBSD's
sopoll_genericnever setsPOLLERR, andpollscanclearsPOLLOUTwhenever it reportsPOLLHUP. Before this change:POLLERRreached the guest as 0x8. A hostPOLLERRon a guest stream socket now becomesPOLLHUPwith the requested read bits, as was already done for pipes.WSAPollreports a peer's close asPOLLHUPalone, soPOLLIN|POLLOUTgave 0x1, and a reset keptPOLLHUP|POLLERRplusPOLLOUT. The half-closed case now adds the requestedPOLLOUTwhile the socket has not shut its own sending side. A remainingPOLLHUPon a stream socket clearsPOLLOUTon Windows too.Datagram sockets were not measured and are unchanged. Both debt entries said "not measured on a console". The Linux one is closed and removed. The Windows one now records the measured behaviour and starts with what still differs (libSceNet sockets, early return with no events).
Before and after
pollresult for events 0 /POLLIN/POLLIN|POLLOUTPOLLHUP|POLLERR, withPOLLOUTTested
e9177a54e9:mainwas merged in, with #14206.main()inGuestPoll.cppnow callsPollsAPipeClosedDuringTheWaitafterPollsAResetStream, andPollsAHungUpSocketWithoutPolloutstays unguarded as in this PR.guest_pollpasses three runs in a row on Windows (MinGW, GCC 15.2) and on Linux (WSL, GCC);check_conventionspasses.38a1d55d1e:mainwas merged in, with #12741. Onlylibkernel.mdmet: it keeps #12741's macOSEV_CLEARwording and this PR's singlepollentry.guest_pollpasses three runs in a row on Windows (MinGW, GCC 15.2) and on Linux (WSL, GCC);check_conventionspasses.Windows 11, WinLibs GCC 15.2, full build. The
polland socket tests pass 3 times out of 3 (62 of 63 matchingpoll|socket|select).select_testsis the Python tool testtools/tests/test_select_tests.py, matched by name. It fails the same way without this change (aFileExistsErrorin its temporary directory on this machine).guest_pollhas a newPollsAResetStream, which checks:POLLINandPOLLIN|POLLOUT;recvgivesECONNRESET.PollsAHungUpSocketWithoutPolloutused to be Linux only and now runs and passes on Windows too.tools/check_conventions.pypasses.Those runs were at head
e014d678abonmainb90d009d9f. After #10456 landed,main2b5225605bwas merged in (head3bc4280f10, thepolldebt entry conflict resolved keepingmain's descriptor 0 to 2 text):guest_pollpasses 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and 3 times out of 3 on Linux (WSL), andtools/check_conventions.pypasses.2ac12a0f9a: main merged in after #9509 and #10456 landed (theirreventscollect step kept, the streamPOLLERR/POLLHUPmapping re-applied on top).guest_pollpasses three runs in a row on Windows 11 (MinGW) and on Linux (WSL, GCC);tools/check_conventions.pypasses.79435a2bcb: mainca96807e83merged in after #13738 landed (its firstpolldebt entry andfstatwording kept, this PR's single Windowspollentry kept, the Linux entry stays removed).guest_pollpasses three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL, GCC);tools/check_conventions.pypasses.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)pollcode inUdp.cppand thepolldebt entries next to these), #13560 (it rewrites the twokeventdebt entries right after thesepollentries indocs/dev/debt/libkernel.md), #15518 (it rewrites thekevent EV_CLEARdebt entry right after thesepollentries); merge order onlyImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T22:36:32Z.
Review: APPROVED
I checked the source and console log in the linked
ppollhupgist: the probe requests no events,POLLIN, andPOLLIN|POLLOUTacross an open socket, peer close, each shutdown direction and an abortive reset. The observed reset result (0x10/0x11/0x11, thenECONNRESET) matches the new test and mapping. The Windows translation is restricted to registered stream sockets; datagrams and pipes retain their separate handling.git diff --checkand current-main conventions pass. Hosted eligibility, conventions, intake, labels and report pass; product builds are skipped by policy. The author reports the focused Windows tests passing; I did not rerun them locally. No concrete defect found.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:49:57Z.
Review: APPROVED
Re-reviewed exact head
3bc4280f10a2dfa04c8bdc8dcf51876ec971e4b8after the merge of #10456. The stream-socket mapping still matches the recorded console results: peer half-close preserves requestedPOLLOUT, local send shutdown or reset clears it, and resetPOLLERRmaps toPOLLHUPwhile retaining requested read bits. The added reset test checks both returned masks and the subsequentECONNRESET; the Windows closed-peer test now covers its previous platform gap. The author reports the focused poll tests 3/3 on Windows and Linux after the main merge. #9509 and #11223 remain listed as merge-order dependencies; #10456 is now merged and present in the base. Hosted policy checks pass; product checks are skipped by path policy, and I did not independently rerun the guest tests.