Commit Graph
5 Commits
Author SHA1 Message Date
Dean de2e6728f3 Merge pull request #8616 from Lindamea1/fix/libkernel-posix-sem-post-notify-under-lock
fix(libkernel): notify a POSIX semaphore waiter before sem_post releases its lock
2026-10-26 11:02:29 +13:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Lindamea1andClaude Opus 5.5 47b5a750ad fix(libkernel): notify a POSIX semaphore waiter before sem_post releases its lock
sem_post raised the count under the semaphore's lock, released the
lock, and only then called NotifyOne on the heap PosixSemaphore. A
thread that took the count in that gap could call sem_destroy, which
deletes the object, and the poster then ran NotifyOne on freed memory.
FreeBSD 11.4's sem_post touches only the caller's sem_t after it
publishes the token, and its sem_destroy only clears _magic, so a
thread may destroy the semaphore as soon as its wait returns.

Call NotifyOne before the lock is released. A thread takes the count
only under that lock, so the unlock is the poster's last access.
guest_posix_sem_post now runs 20000 rounds that post to a semaphore
the main thread destroys once sem_trywait gets the count; with the old
order the poster crashes in NotifyOne.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 19:30:14 +01:00
MarcZX100andmilescoviello 8935160160 fix(libkernel): handle available sem_timedwait counts first
Co-authored-by: milescoviello <[email protected]>
2026-10-11 23:54:18 +02:00
RomainROCH eae05782af fix(libkernel): enforce POSIX semaphore count limits 2026-10-03 04:03:25 +02:00