11 Commits
Author SHA1 Message Date
Dean a4ebd9084c Merge pull request #26801 from methmoussa/fix/kmq-copy-in-guest-inputs
fix(libkernel_sys): copy kmq message and deadline in from guest memory
2026-11-28 14:23:35 +13:00
methmoussaandClaude Opus 5.5 cfc1b33ea8 fix(libkernel_sys): copy kmq message and deadline in from guest memory
kmq_timedsend built its queued message straight from the guest pointer
and both timed calls read abstime through it, so an unreadable pointer
faulted the host. Copy both through GuestCopyIn and fail with EFAULT,
reading the deadline right after the descriptor check as FreeBSD's
sys_kmq_timedsend and sys_kmq_timedreceive do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 17:09:51 -05:00
Mohamed Malek Aifa 75fc81fdb1 test(libkernel): cover production mqueue monotonic waits 2026-11-20 05:11:57 +01:00
Mohamed Malek Aifa 43af1695a1 fix(libkernel): use monotonic message queue waits 2026-11-19 09:00:56 +01:00
pushkarreddyy e79605024c fix(libkernel_sys): restrict attribute probing in kmq_open to O_CREAT 2026-11-16 14:13:23 +05:30
pushkarreddyy 7f38ccbb9d fix(libkernel_sys): preserve caller errno across attribute probing in kmq_open and kmq_setattr 2026-11-16 14:07:57 +05:30
pushkarreddyy b0a89feca0 fix(libkernel_sys): safely probe guest attribute pointers in kmq_open and kmq_setattr 2026-11-16 13:35:47 +05:30
kattkaries 67ee1319c5 fix(libkernel_sys): probe guest output in kmq_timedreceive
kmq_timedreceive_nid_postfix copied the message into the caller's buffer
with memcpy and stored the priority with *priority = ..., both guest
pointers, after only a null check, so a non-null but unmapped buffer or
priority faulted the process. Both writes now go through
GuestCopyOut_nid_no_patch: on an inaccessible output it restores the
caller's errno and returns EFAULT. Host callers pass stack buffers, which
GuestCopyOut writes like any mapped address.
2026-11-15 06:23:50 +01:00
tablefrogpillowandClaude Opus 4.8 11b5a0dafc refactor(libkernel_sys): declare the mqueue exports in Api.hpp and bound the deadline per clock
Declare kmq_open/setattr/timedsend/timedreceive/unlink once in Api.hpp with their
real signatures and the GuestMqAttr/GuestTimespec types, and include Api.hpp (plus
GuestErrno.hpp and Equeue.hpp for __error and the descriptor-close observer) from
Mqueue.cpp and the test instead of local extern "C" blocks and duplicate types.

Deadline summed seconds and nanoseconds in nanoseconds, so on a microsecond
system_clock a tv_sec between about 9.2e9 and 9.2e12 passed the clock-range guard
and still overflowed; each part is now cast to the clock's duration before adding.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-09 19:44:55 +00:00
tablefrogpillowandClaude Opus 4.8 198bfe50f9 fix(libkernel_sys): guard the mqueue nonblocking flag, reject a null receive buffer and saturate the deadline
kmq_setattr wrote open->nonblocking outside queue.lock while WaitFor reads it
under the lock, racing concurrent mq_setattr with send and receive; the write
and the old-attribute snapshot now share the readers' lock.

kmq_timedreceive copied into buffer after dequeuing the message, so a null
buffer crashed the host and lost the message; it is now rejected with EFAULT
before the queue is touched, matching kmq_timedsend.

Deadline converted tv_sec to int64 nanoseconds, overflowing for a tv_sec near
INT64_MAX ("forever") and wrapping to an immediate timeout; it now saturates
to the clock's representable range.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-09 19:35:31 +00:00
David dfc5804e5f feat(libkernel_sys): implement POSIX message queues 2026-11-09 13:11:23 +00:00