fchown, fstat and ioctl on a kqueue descriptor answer like a null device, FreeBSD answers EINVAL, S_IFIFO and ENOTTY #10015

Closed
opened 2026-10-23 04:08:35 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-23 04:08:35 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-23T04:08:35Z.


A kqueue descriptor is backed by a placeholder host handle (NUL on Windows, /dev/null on POSIX hosts), and three calls answer it as that character device instead of as a kqueue: fchown(kq, 0, 0) returns 0 where FreeBSD 11.4 returns EINVAL (invfo_chown, sys/kern/kern_descrip.c:4076); fstat(kq) reports the placeholder's type where FreeBSD's kqueue_stat (sys/kern/kern_event.c:1928) zeroes the struct and sets st_mode = S_IFIFO; and ioctl(kq, <request>) reaches the "unsupported request" throw where FreeBSD's kqueue_ioctl (kern_event.c:1853) returns ENOTTY. Found by comparing the descriptor operations against the FreeBSD 11.4 source, not from a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5991702495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10015). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-23T04:08:35Z. --- A kqueue descriptor is backed by a placeholder host handle (`NUL` on Windows, `/dev/null` on POSIX hosts), and three calls answer it as that character device instead of as a kqueue: `fchown(kq, 0, 0)` returns 0 where FreeBSD 11.4 returns EINVAL (`invfo_chown`, sys/kern/kern_descrip.c:4076); `fstat(kq)` reports the placeholder's type where FreeBSD's `kqueue_stat` (sys/kern/kern_event.c:1928) zeroes the struct and sets `st_mode = S_IFIFO`; and `ioctl(kq, <request>)` reaches the "unsupported request" throw where FreeBSD's `kqueue_ioctl` (kern_event.c:1853) returns ENOTTY. Found by comparing the descriptor operations against the FreeBSD 11.4 source, not from a title. AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#10015
No description provided.