Skip to content

feat(libkernel): answer tcgetpgrp and tcsetpgrp on a pipe with its SIGIO owner - #9566

Open
DavidSamir wants to merge 9 commits into
boykopovar:mainfrom
DavidSamir:feat/libkernel-tcpgrp-pipe
Open

DavidSamir wants to merge 9 commits into
boykopovar:mainfrom
DavidSamir:feat/libkernel-tcpgrp-pipe

Conversation

@DavidSamir

@DavidSamir DavidSamir commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Builds on #9557. Until #9557 merges, this PR's diff also shows its commit. This PR's own change is the last commit.

tcgetpgrp and tcsetpgrp threw on a host pipe or FIFO above descriptor 2, because the pipe's SIGIO owner was not modelled. #9557 now keeps that owner, so they follow FreeBSD 11:

  • The libc side: tcsetpgrp is _ioctl(fd, TIOCSPGRP, &pgrp) and tcgetpgrp is _ioctl(fd, TIOCGPGRP, &s) (lib/libc/gen/termios.c:82-99).
  • The pipe side: pipe_ioctl answers TIOCSPGRP with fsetown(-pgrp) and TIOCGPGRP with -fgetown() (sys/kern/sys_pipe.c:1402-1410). So these use the same owner as F_SETOWN/FIOSETOWN, with the sign reversed: after F_SETOWN(pid), tcgetpgrp returns -pid.

How:

  • Terminal.cpp: on a host pipe or FIFO at descriptor 3 or above, tcgetpgrp and tcsetpgrp call File::PipeProcessGroup and File::SetPipeProcessGroup instead of throwing. The same fsetown rules apply: 0 clears, our own process group is stored, and any other group gives ESRCH. Descriptors 0 to 2 keep their documented ENOTTY, since they're taken as non-terminals that aren't pipes.
  • DescriptorControl.cpp: the two helpers. The raw TIOCSPGRP (0x80047476) and TIOCGPGRP (0x40047477) ioctls now give the same answer on such a pipe, ahead of the terminal-group ENOTTY.
  • The debt line for the terminal functions (docs/dev/debt/libkernel.md:128) replaces its "throw on a host pipe" clause.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release. This is CPU-side, so no GPU is involved.

guest_terminal (core/libs/tests/GuestTerminal.cpp): in the pipe loop, the two checks that expected a throw now check:

  • a group of 0 at first, then setting and getting our group;
  • ESRCH for another group, with the owner kept;
  • F_SETOWN(pid) making tcgetpgrp return -pid, and the reverse;
  • the TIOCSPGRP/TIOCGPGRP ioctls;
  • clearing with 0.

Results:

Checklist

…GIO owner

FreeBSD's tcgetpgrp and tcsetpgrp are the TIOCGPGRP and TIOCSPGRP
ioctls, which pipe_ioctl answers through fgetown and fsetown on the
pipe's SIGIO owner. Builds on the owner kept for F_GETOWN/F_SETOWN.
@github-actions

github-actions Bot commented Oct 22, 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 6149 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7121 core/libs/prx/libkernel/File/include/DescriptorControl.hpp
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
docs/dev/debt/libkernel.md
PR 8605 docs/dev/debt/libkernel.md
PR 9938 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 10558 docs/dev/debt/libkernel.md
PR 11215 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 12544 core/libs/prx/libkernel/CMakeLists.txt
PR 12682 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 12688 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 12700 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/include/DescriptorControl.hpp
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 12965 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/include/DescriptorControl.hpp
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 14103 docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 15037 docs/dev/debt/libkernel.md
PR 15040 docs/dev/debt/libkernel.md
PR 16372 core/libs/prx/libkernel/CMakeLists.txt
PR 16790 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 16826 docs/dev/debt/libkernel.md
PR 17439 core/libs/prx/libkernel/CMakeLists.txt
PR 17463 core/libs/prx/libkernel/CMakeLists.txt
PR 17484 core/libs/prx/libkernel/CMakeLists.txt
PR 17513 core/libs/prx/libkernel/CMakeLists.txt
PR 18112 core/libs/prx/libkernel/CMakeLists.txt
PR 18190 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/File/src/Terminal.cpp
PR 18293 core/libs/prx/libkernel/CMakeLists.txt
PR 18324 docs/dev/debt/libkernel.md
PR 18462 docs/dev/debt/libkernel.md
PR 19181 core/libs/prx/libkernel/CMakeLists.txt
PR 20161 docs/dev/debt/libkernel.md
PR 21026 core/libs/prx/libkernel/CMakeLists.txt
PR 21058 core/libs/prx/libkernel/CMakeLists.txt
PR 21132 core/libs/prx/libkernel/CMakeLists.txt
PR 21135 core/libs/prx/libkernel/CMakeLists.txt
PR 21604 core/libs/prx/libkernel/CMakeLists.txt
PR 21625 core/libs/prx/libkernel/CMakeLists.txt
PR 21626 core/libs/prx/libkernel/CMakeLists.txt
PR 21655 core/libs/prx/libkernel/CMakeLists.txt
PR 21663 core/libs/prx/libkernel/CMakeLists.txt
PR 22391 core/libs/prx/libkernel/CMakeLists.txt
PR 22479 core/libs/prx/libkernel/CMakeLists.txt
PR 24343 core/libs/prx/libkernel/CMakeLists.txt
PR 24489 core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 25949 core/libs/prx/libkernel/CMakeLists.txt
PR 26174 core/libs/prx/libkernel/CMakeLists.txt
PR 26206 core/libs/prx/libkernel/CMakeLists.txt
PR 27539 core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 27563 core/libs/prx/libkernel/CMakeLists.txt
PR 27717 core/libs/prx/libkernel/CMakeLists.txt
PR 27813 core/libs/prx/libkernel/CMakeLists.txt
PR 27864 core/libs/prx/libkernel/CMakeLists.txt
PR 28043 core/libs/prx/libkernel/CMakeLists.txt
PR 28045 core/libs/prx/libkernel/CMakeLists.txt
PR 28051 core/libs/prx/libkernel/CMakeLists.txt
PR 28175 core/libs/prx/libkernel/File/include/DescriptorControl.hpp
core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 28205 core/libs/prx/libkernel/File/src/DescriptorControl.cpp
PR 28253 core/libs/prx/libkernel/CMakeLists.txt
PR 28299 core/libs/prx/libkernel/CMakeLists.txt
PR 28323 core/libs/prx/libkernel/CMakeLists.txt
PR 28434 core/libs/prx/libkernel/CMakeLists.txt
PR 28702 core/libs/prx/libkernel/CMakeLists.txt
PR 28770 core/libs/prx/libkernel/CMakeLists.txt
PR 28801 core/libs/prx/libkernel/CMakeLists.txt
PR 28808 core/libs/prx/libkernel/CMakeLists.txt
PR 28815 core/libs/prx/libkernel/CMakeLists.txt

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

First run on Linux (the PR is tested on Windows only). Ubuntu 26.04, x86_64, Intel i7-8700, GCC 15.2.0, Release, BUILD_TESTING=ON, head e846772 merged --no-commit onto current origin/main (6ef5a1c).

  • Build: ok.
  • ctest -R "guest_kernel_fcntl_owner|guest_terminal" with the PR: both pass.
  • Negative control (revert DescriptorControl.cpp/.hpp and Terminal.cpp to origin/main, keep the tests): both abort with the real assert
terminate called after throwing an instance of 'std::runtime_error'
  what():  fcntl: F_GETOWN on a pipe is not implemented, fd=6
  • Restoring the PR implementation: both pass again.

So the pipe SIGIO-owner path (F_GETOWN/F_SETOWN, FIO[GS]ETOWN, TIOC[GS]PGRP) is exercised on Linux and the tests genuinely fail without it.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

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

The pipe SIGIO owner path is covered by focused owner/terminal tests, including the group/owner sign reversal, and the reported Linux negative-control run exercises the implementation. The declared #9557 prerequisite is correct. Hosted conventions, eligibility, intake, labels and report checks pass; product and relinker jobs are skipped. I did not run tests locally.

I cannot complete the overlap requirement yet. The PR description identifies a direct GuestTerminal.cpp overlap with #9242 and says whichever lands second should rebase, but it does not record agreement with #9242’s author or an agreed order. Please coordinate with that author; if either change must land first, state the order and add the corresponding Depends on entry. Preserve both sets of tests through the merge. The other overlap rows you list should likewise have an explicit agreed integration order wherever the actual changed lines conflict.

@MarcZX10

Copy link
Copy Markdown
Contributor

The PR description identifies the GuestTerminal.cpp overlap with #9242 but does not record an agreed order with its author. Please coordinate before merge; if one must land first, state the order and add the matching Depends on entry. Keep both test additions through the rebase. The declared #9557 prerequisite is appropriate.

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

Checked against main 4a17c71, #9557's head c375560 (this PR's parent commit), and FreeBSD releng/11.4 (sys/kern/sys_pipe.c:1401-1410, lib/libc/gen/termios.c):

  • The sign reversal between owner and group matches pipe_ioctl, and tcgetpgrp/tcsetpgrp reuse the #9557 rules. Nothing here duplicates #9557; it just needs to land after it.
  • The ioctl, _ioctl debt entry (docs/dev/debt/libkernel.md:220) still says every group-t termios request fails with ENOTTY. With this PR, TIOCSPGRP and TIOCGPGRP on a pipe above fd 2 now succeed (DescriptorControl.cpp:601-609). Could that entry mention the exception?
  • Nit: -group in SetPipeProcessGroup and -*static_cast<const int*>(argument) (:602) overflow for INT_MIN. The result happens to be ESRCH, as on FreeBSD, but it depends on undefined behaviour. An explicit INT_MIN → ESRCH check would make it well-defined.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

@EagleBearerYS

Copy link
Copy Markdown
Contributor

@DavidSamir a merge-order note: #9491 adds a sceKernelWaitSema/sceKernelSignalSema entry to docs/dev/debt/libkernel.md right before the tcsendbreak … tcsetpgrp entry this PR changes, and the two conflict in that file only. Their code doesn't meet. Neither needs to wait for the other: if this PR merges first, #9491 rebases and keeps your entry, and if #9491 merges first, I can put the resolved file on a branch of my fork for you to take.

…cked read

FIOSETOWN and FIONBIO read their int argument by dereferencing the guest
pointer, so an unreadable non-null pointer faulted the host instead of
failing with EFAULT. Both now copy the int in with ReadProcessMemory,
process_vm_readv or mach_vm_read_overwrite. The owner test covers a null
and an unreadable argument. The debt line notes that a host socket that is
not a guest socket still throws, and that two opens of one FIFO keep
separate owners.
…group

The process-group setters negated the group to store it as a SIGIO owner,
which is undefined for INT_MIN. INT_MIN now fails with ESRCH before the
negation, and TIOCSPGRP copies its argument in with the checked read, so an
unreadable pointer gives EFAULT. The ioctl debt line names the TIOCSPGRP
and TIOCGPGRP exception on a pipe.
@DavidSamir

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX10 and @harisibrar1. New commits, no force-push:

  • Merge of feat(libkernel): keep the SIGIO owner of a pipe for F_GETOWN and F_SETOWN #9557's updated head: brings in its checked FIOSETOWN/FIONBIO copy-in.
  • ecd4a973f9:
    • tcsetpgrp and TIOCSPGRP go through one setter that fails INT_MIN with ESRCH before negating, so the result no longer depends on undefined behaviour. As @harisibrar1 said, the old code already gave ESRCH on this compiler, so the new GuestTerminal case (tcsetpgrp(end, INT_MIN) fails with ESRCH and keeps the group) passes either way. A negative control can't tell them apart here; it guards the UB.
    • TIOCSPGRP now copies its argument in with the same checked read as FIOSETOWN. GuestTerminal checks that an unreadable pointer (0x10) gives EFAULT and leaves the owner unchanged.
    • The ioctl, _ioctl debt line now names the exception: TIOCSPGRP and TIOCGPGRP on a pipe above descriptor 2 set and read the pipe's SIGIO group, as pipe_ioctl does.
  • ecd4a973f9: merges current main.

Re-run on the merge (Windows 11, WinLibs GCC 15.2): guest_terminal, guest_kernel_fcntl, guest_kernel_fcntl_owner and guest_append_writes pass, and check_conventions.py reports 0 errors. Its 3 warnings are debt entries already over 1000 characters on main.

On the overlaps: #9242 is ours as well (the same fork), so we'll order the two GuestTerminal.cpp changes between us and record it. @EagleBearerYS, thanks for the #9491 note. Either order works as you describe, and whichever lands second keeps both entries.

AI-assisted: yes

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

Re-ran on Linux at ecd4a97 (follow-up to my earlier run at e846772). The new ReadGuestInt uses the process_vm_readv branch here, which the Windows run doesn't exercise.

Ubuntu 26.04, x86_64, i7-8700, GCC 15.2.0, Release, head merged --no-commit onto origin/main 7e2ba73.

  • ctest -R "guest_kernel_fcntl|guest_terminal": 3/3 pass.
  • Control: DescriptorControl.cpp from e846772, tests from ecd4a97: guest_terminal and guest_kernel_fcntl_owner both die with SIGSEGV (the new 0x10 argument cases dereferenced directly). With the head's file both pass, so process_vm_readv returns EFAULT cleanly for the unreadable pointer.
  • ASan+UBSan build (-fsanitize=address,undefined -fno-sanitize-recover=undefined, -O1): with the head, both tests pass with no reports. With the e846772 DescriptorControl.cpp, guest_terminal stops at the new INT_MIN case with:
DescriptorControl.cpp:464:25: runtime error: negation of -2147483648 cannot be represented in type 'int'

So the INT_MIN check in SetProcessGroup removes a real UB that UBSan flags on this path.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@DavidSamir DavidSamir mentioned this pull request Oct 22, 2026
12 tasks done
@DavidSamir

Copy link
Copy Markdown
Contributor Author

@MarcZX10 the integration order is now recorded in the description:

The prerequisite stays #9557.

AI-assisted: yes

@DavidSamir

Copy link
Copy Markdown
Contributor Author

@jotitadev thank you, especially for the UBSan run. It shows the INT_MIN negation was real undefined behaviour (negation of -2147483648 cannot be represented in type 'int'), not just a theoretical one, and that the new check removes it. I had written that no negative control could show this; yours does.

AI-assisted: yes

@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Rechecked head ecd4a973f9ad8995a6d6d87153a5a033fd746af9: it contains #9557 as a prerequisite, records the no-wait agreements with #9242 and #9491, and retains both the process-group tests and debt exceptions. The follow-up also fixes the concrete INT_MIN negation UB and checks unreadable TIOCSPGRP copy-in. Current-base diff --check passes; conventions has zero errors and three debt-length warnings. check_main_sync.py reports 6 ahead / 11 behind (d6eafa54d merge base), clean merge. The detailed Windows and Linux/UBSan runs in the PR/review comments are author/reviewer-reported; product hosted jobs are skipped, and I could not run another local build because the filesystem is full. No new blocking finding.

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

Rechecked at ecd4a97:

  • SetProcessGroup now returns ESRCH for INT_MIN before negating (DescriptorControl.cpp:470-473), and the stored owner can only be 0 or ±pid, so the remaining -GetSigioOwner negations are safe too. The result still matches FreeBSD's fsetown.
  • TIOCSPGRP now goes through the checked ReadGuestInt (:641-644), and the ioctl, _ioctl debt entry names the TIOCSPGRP/TIOCGPGRP exception on a pipe above fd 2. Both of my points are addressed; it still needs to land after #9557.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

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

The earlier technical findings are addressed in this head: the INT_MIN case is rejected before negation, TIOCSPGRP uses checked guest copy-in, and the debt text records the pipe ioctl exception. I verified the current #9557 head f8698a0b663a95a51f59839c42e245bf0f5598e0 is an ancestor of this PR, so the declared prerequisite is present. #9242 and #9491 remain open at 028ccac1 and d1604d79; the stated no-wait agreements cover their test/debt overlaps.

Current upstream/main is 329efe1bfdaff116c57cdf62718026ee4f5521ae. This PR is 6 ahead / 56 behind, merge-tree is clean, and current-base git diff --check passes. The current conventions run has zero errors and only the reported inherited debt-length warnings. Main has updated docs/dev/debt/libkernel.md since the PR base, while the changed C++ and test files have no intervening main edits. Please refresh from current main and let conventions run again before merge; then rerun the focused terminal/owner tests if the rebase changes the tested tree. The Windows and Linux/ASan/UBSan runs in the discussion are reporter-run on the current code head; I did not run a local project build here.

@MarcZX10

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

@kali113

kali113 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Console measurement of the pipe cases, in case it is useful for the tests.

PS5, firmware 13.590.001. A payload with pid 101 in process group 91 created a pipe and called tcgetpgrp and tcsetpgrp on both ends from the system libkernel:

call return errno tcgetpgrp afterwards
tcgetpgrp on a fresh pipe, either end 0 0
tcsetpgrp(fd, 0) 0 0 0
tcsetpgrp(fd, 91) (own group) 0 0 91
tcsetpgrp(fd, 101) (own pid, not a group id) -1 3 (ESRCH) unchanged
tcsetpgrp(fd, 12345) and tcsetpgrp(fd, INT_MAX) -1 3 (ESRCH) unchanged
tcsetpgrp(fd, 1) -1 1 (EPERM) unchanged
tcsetpgrp(fd, -1) and tcsetpgrp(fd, -5) -1 1 (EPERM) unchanged

Both ends of the pipe behave the same. For comparison, the same two calls on a Unix socket give EOPNOTSUPP (45), on an IPv4 UDP socket EADDRNOTAVAIL (49), on /dev/null ENOTTY (25) and on a closed descriptor EBADF (9). tcgetsid on a pipe gives ENOTTY and isatty gives 0 with ENOTTY.

@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; the points below are optional.

What I ran

Head 0bc531a0a29be507638f5edaa51645a8169aed4f, base main. Static review only: no build and no test run.

python3 repo_read.py search g_mutex core/libs/prx/libkernel/File
python3 repo_read.py search GuestCopyIn_nid_no_patch core/libs/prx/libkernel
python3 repo_read.py search HostWrite core/libs/prx/libkernel
python3 repo_read.py search GuestArenaPrepareHostRead core/libs/prx/libkernel

Files read: all 7 in files.json under reviewed, none excluded. Terminal.cpp was read in full. DescriptorControl.cpp was read through its changed hunks, plus its head lines 120–159 and 380–439. CMakeLists.txt, GuestKernelFcntlOwner.cpp, GuestTerminal.cpp and libkernel.md were read through their changed hunks only.

Results

Check Result Note
Build not run No builds in this review
Tests not run Author reports a Windows run only
Changed code read passed 7 of 7 files, see above
Lock order and helpers passed No nested lock; helpers exist
Conventions script not run Author reports 0 errors

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libkernel/File/src/DescriptorControl.cpp:621: on Linux, ReadGuestInt throws when process_vm_readv fails with an errno other than EFAULT. The FIONBIO path now reads its argument through this helper (core/libs/prx/libkernel/File/src/DescriptorControl.cpp:654), where it used GuestCopyIn_nid_no_patch before. If the host refuses the call, FIONBIO throws instead of returning a guest error. I did not read the Linux implementation of GuestCopyIn_nid_no_patch, so I cannot say whether the old path could fail the same way.

Sources

Not verified

  • Nothing was compiled or run here. The Linux branch (process_vm_readv) and the macOS branch (mach_vm_read_overwrite) of ReadGuestInt have not been compiled by anyone in this review.
  • The author's Windows run of guest_terminal and guest_kernel_fcntl_owner is author-reported and was not repeated here.
  • The lib/libc/gen/termios.c side of tcgetpgrp and tcsetpgrp, cited in the description, was not read.
  • The FreeBSD behaviour cited in the description and the debt entries (sys_pipe.c) was not checked.
  • The overlap check and the check_conventions.py result are author-reported and were not run.

To get this to a good state

Nothing is required.

Optional: on Linux, return a guest fault for any process_vm_readv failure, or document the throw in the libkernel debt file, so that a restricted host does not turn FIONBIO into an exception.

@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: the debt register now holds duplicate entries that contradict each other on the behaviour this PR changes.

What I ran

  • Head SHA: fd2ec30 (base main).
  • Read the full diff.patch, description.md, commits.md and manifest.json from the review folder.
  • Read the house rules sections "Readable reviews", "Accuracy and evidence" and "Standard PR response format".
  • Repository reads at head through the reader (repo_read.py): search for the debt entries, the mutex and Materialize in DescriptorControl.cpp, the fcntl_nid_postfix declarations; cat of DescriptorControl.cpp lines 136–150 and 396–406.
  • No build and no test run in this review.

Results

Check Result Note
Full diff read passed 428 lines, all 8 changed files
Debt register at head failed Duplicate, contradictory entries
Lock order in GetSigioOwner / Owner passed Materialize takes no lock, so no self-deadlock
Build and CTest not run Not built here
Author's test report not run Author-reported only, not reproduced

Findings

Blocking

  • docs/dev/debt/libkernel.md:189 (added at diff lines 408–410): the PR adds a new tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp, tcsetpgrp entry, but the old entry stays at docs/dev/debt/libkernel.md:194. The new entry says tcgetpgrp and tcsetpgrp use the pipe's SIGIO owner; the old one says they throw on a host pipe. The same goes for sem_setname (187 and 191) and kevent measurements (188 and 192): the copies disagree on what a null name returns (EINVAL at 191, a throw at 187).
    • Failure scenario: a reader of the debt register gets two opposite answers for tcgetpgrp on a pipe. The code now implements the pipe-owner answer, so the entry at 194 is stale.
    • Fix: keep one entry per export. Drop the old tcsendbreak entry at 194 and the old copies at 191–192, and check Pthread/Posix/Sem.cpp and Equeue/src/Kqueue.cpp at head to decide which sem_setname and kevent text is right. Those two are unrelated to this PR, so they belong in a separate change or should be removed from this one.

Non-blocking

  • description.md says the terminal entry sits at docs/dev/debt/libkernel.md:128 and that its throw clause is replaced. The diff touches lines 187–189 and 355–361 only, and the old entry is at 194. Point the description at the real lines once the duplicates are gone.

Not verified

  • Build, CTest, and the new guest_kernel_fcntl_owner test under CMake on any host.
  • The author's test results (guest_terminal and guest_kernel_fcntl_owner, 3 of 3 runs, and the negative controls at lines 120 and 121). Author-reported only.
  • The author's character counts for the terminal debt entry (1047 against 1131).
  • Host behaviour of the calls the code relies on: process_vm_readv on Linux, mach_vm_read_overwrite on macOS, ReadProcessMemory on Windows.
  • std::erase_if on std::map and the <map> and <memory> includes; the ENVIRONMENT_MODIFICATION block in CMakeLists.txt for Windows.
  • The PS5 claims in the debt entries. These cannot be checked from the repository.
  • The overlap claims against #9557, #9242, #9491, #9131, #7121, #8520, #9019 and #9561.
  • Files read: the four review-folder files and the diff in full, plus the head text of DescriptorControl.cpp at 136–150 and 396–406. Not read: the files/ full texts, files.json, the head text of Terminal.cpp, CMakeLists.txt, the two test files, and Api.hpp beyond the grep. Lockfiles, minified files, dist/, build/ and .svg are excluded from the diff by rule.

To get this to a good state

  • Remove the duplicate debt entries so each export has one entry with one answer (see the blocking finding).
  • Fix the description's pointer to the debt entry.
  • On the new head, rerun guest_terminal and guest_kernel_fcntl_owner and attach the output.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

This passed review on fd2ec30, but it now conflicts with main in DescriptorControl.cpp. Please merge main into the branch and push; it goes back to the merge queue on the new head.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@DavidSamir the code is fine; one docs fix. This PR adds ten lines straight to docs/dev/debt/libkernel.md, and at this head the tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp, tcsetpgrp entry is there twice (line 189 says a pipe answers with its SIGIO owner, line 194 still says it throws), and the sem_setname and kevent entries are duplicated too, with copies that disagree (187 and 191, 188 and 192). Please update the one existing tc* entry for the pipe answer and drop the other added lines; the sem_setname and kevent text is not part of this change.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiled the changed descriptor and terminal sources with GuestKernelFcntlOwner and GuestTerminal against the existing Linux PRXs. Both fixtures passed, including process-group handling on the pipe endpoints.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants