History log of /freebsd/sys/kern/kern_umtx.c (Results 1 – 25 of 398)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 50c1e179 05-Jan-2025 Kristof Provost <kp@FreeBSD.org>

umtx: handle allocation failire in umtx_pi_alloc()

Don't assume that this allocation will succeed. We may have been passed
M_NOWAIT.

The calling code already handles allocation failures, but the fu

umtx: handle allocation failire in umtx_pi_alloc()

Don't assume that this allocation will succeed. We may have been passed
M_NOWAIT.

The calling code already handles allocation failures, but the function
itself did not.

PR: 283807
MFC after: 1 week

show more ...


# f3b7dbda 04-Dec-2024 Mark Johnston <markj@FreeBSD.org>

shm: Handle swap pager allocation failures

shm_alloc() can fail if swap reservation fails (i.e., vm.overcommit is
non-zero) or racct is imposing some limits on swap usage.

PR: 282994
MFC after: 2

shm: Handle swap pager allocation failures

shm_alloc() can fail if swap reservation fails (i.e., vm.overcommit is
non-zero) or racct is imposing some limits on swap usage.

PR: 282994
MFC after: 2 weeks
Reviewed by: olce, kib
Differential Revision: https://reviews.freebsd.org/D47839

show more ...


Revision tags: release/14.2.0
# f6607778 13-Nov-2024 Kyle Evans <kevans@FreeBSD.org>

_utmx_op: don't recurse on chain busy

In handling a PP mutex, we'll busy it as soon as we enter the loop and
unbusy it either prior to sleeping or at exit time. In this particular
case, if we fail

_utmx_op: don't recurse on chain busy

In handling a PP mutex, we'll busy it as soon as we enter the loop and
unbusy it either prior to sleeping or at exit time. In this particular
case, if we fail to transition the mutex from OWNERDEAD -> owned because
of casueword(9) failure and the suspend check fails, we'll start over
and attempt to busy an already-busied chain and irrecoverably lock up
both this thread and anything else that tries to busy the chain.

Unbusy the chain prior to restarting because I couldn't decide if that
was a better or worse idea than just keeping track of whether we dirtied
it in do_lock_pp() and avoiding re-dirty. This is marginally easier to
reason about as it returns us to expected state on entry to the loop.

While we're here, simplify the code a bit as `error` will be clobbered
right after the branch anyways.

Reviewed by: kib, olce (both earlier version)
Differential Revision: https://reviews.freebsd.org/D47493

show more ...


Revision tags: release/13.4.0
# c75a1890 04-Sep-2024 Olivier Certner <olce@FreeBSD.org>

umtx: shm: 'ushm_refcnt > 0' => 'ushm_refcnt != 0'

'ushm_refcnt' is unsigned. Don't leave the impression it isn't.

No functional change (intended).

Reviewed by: kib
Approved by: emaste (men

umtx: shm: 'ushm_refcnt > 0' => 'ushm_refcnt != 0'

'ushm_refcnt' is unsigned. Don't leave the impression it isn't.

No functional change (intended).

Reviewed by: kib
Approved by: emaste (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46126

show more ...


# c3e6dfe5 04-Sep-2024 Olivier Certner <olce@FreeBSD.org>

umtx: shm: Prevent reference counting overflow

This hardens against provoked use-after-free occurences should there be
reference counting leaks in the future (which is currently not the
case).

At t

umtx: shm: Prevent reference counting overflow

This hardens against provoked use-after-free occurences should there be
reference counting leaks in the future (which is currently not the
case).

At the deepest level, umtx_shm_find_reg_unlocked() now returns EOVERFLOW
when it cannot grant an additional reference to the registry object, and
so will umtx_shm_find_reg(). umtx_shm_create_reg() will fail if calling
umtx_shm_find_reg() returns EOVERFLOW (meaning a SHM object for the
passed key already exists, but we can't acquire another reference on
it), avoiding the creation of a duplicate registry entry for a given key
(this wouldn't pose problem for the rest of the code in its current
form, but is expressly avoided for intelligibility and hardening
purposes).

Since umtx_shm_find_reg*(), and consequently the whole _umtx_op() system
call, can only return EOVERFLOW on such a bug manifesting, we don't
document that return value.

Reviewed by: kib, emaste
Approved by: emaste (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46126

show more ...


# 62f40433 04-Sep-2024 Olivier Certner <olce@FreeBSD.org>

umtx: shm: Fix use-after-free due to multiple drops of the registry reference

umtx_shm_unref_reg_locked() would unconditionally drop the "registry"
reference, tied to USHMF_LINKED.

This is not a pr

umtx: shm: Fix use-after-free due to multiple drops of the registry reference

umtx_shm_unref_reg_locked() would unconditionally drop the "registry"
reference, tied to USHMF_LINKED.

This is not a problem for caller umtx_shm_object_terminated(), which
operates under the 'umtx_shm_lock' lock end-to-end, but it is for
indirect caller umtx_shm(), which drops the lock between
umtx_shm_find_reg() and the call to umtx_shm_unref_reg(true) that
deregisters the umtx shared region (from 'umtx_shm_registry';
umtx_shm_find_reg() only finds registered shared mutexes).

Thus, two concurrent user-space callers of _umtx_op() with UMTX_OP_SHM
and flags UMTX_SHM_DESTROY, both progressing past umtx_shm_find_reg()
but before umtx_shm_unref_reg(true), would then decrease twice the
reference count for the single reference standing for the shared mutex's
registration.

Reported by: Synacktiv
Reviewed by: kib
Approved by: emaste (mentor)
Security: FreeBSD-SA-24:14.umtx
Security: CVE-2024-43102
Security: CAP-01
Sponsored by: The Alpha-Omega Project
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46126

show more ...


# dd83da53 04-Sep-2024 Olivier Certner <olce@FreeBSD.org>

umtx: shm: Collapse USHMF_REG_LINKED and USHMF_OBJ_LINKED flags

...into the only USHMF_LINKED, as they are always set or unset together.

This is both to stop giving the impression that they can be

umtx: shm: Collapse USHMF_REG_LINKED and USHMF_OBJ_LINKED flags

...into the only USHMF_LINKED, as they are always set or unset together.

This is both to stop giving the impression that they can be set/unset
independently, which they can't with the current code, and to make it
clearer that an upcoming reference counting fix is correct.

Reviewed by: kib
Approved by: emaste (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46126

show more ...


Revision tags: release/14.1.0
# 6bb132ba 15-Apr-2024 Brooks Davis <brooks@FreeBSD.org>

Reduce reliance on sys/sysproto.h pollution

Add sys/errno.h, sys/malloc.h, sys/queue.h, and vm/uma.h as needed.

sys/sysproto.h currently includes sys/acl.h which currently includes
sys/param.h, sys

Reduce reliance on sys/sysproto.h pollution

Add sys/errno.h, sys/malloc.h, sys/queue.h, and vm/uma.h as needed.

sys/sysproto.h currently includes sys/acl.h which currently includes
sys/param.h, sys/queue.h, and vm/uma.h which in turn bring in
sys/errno.h sys/malloc.h.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D44465

show more ...


Revision tags: release/13.3.0
# 39e4665c 22-Feb-2024 Olivier Certner <olce@FreeBSD.org>

PP mutexes: lock: Reduce 'umtx_lock' holding before taking the user lock

There is no need to have it for the priority check (that the thread
doesn't have a higher priority than the mutex's ceiling),

PP mutexes: lock: Reduce 'umtx_lock' holding before taking the user lock

There is no need to have it for the priority check (that the thread
doesn't have a higher priority than the mutex's ceiling), and there's
also no need to take it if the thread doesn't have privileges to set its
priority to the mutex's ceiling.

While here, turn 'su' into a 'bool' and compute the internal priority
corresponding to the mutex's ceiling once and for all, putting it in new
'new_pri'.

Reviewed by: kib
Approved by: emaste (mentor)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44045

show more ...


# 9ac3ac9e 22-Feb-2024 Olivier Certner <olce@FreeBSD.org>

PP mutexes: lock: Check if priority is too high against base one

Doing this instead of using the current (user) priority, which includes
current lendings, prevents gratuitous failures for threads in

PP mutexes: lock: Check if priority is too high against base one

Doing this instead of using the current (user) priority, which includes
current lendings, prevents gratuitous failures for threads involved in
multiple locking groups, where each group is defined as the threads that
can lock a particular PP or PI mutex. No deadlock can occur in this
case. Indeed, if a thread holds such a lock A giving it a higher
priority than the ceiling of some other lock B that is PP, and B is
acquired by another thread, effectively the latter may not be able to
run but this situation can only last until the first thread releases A,
which it will do eventually.

Reviewed by: kib
Approved by: emaste (mentor)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44044

show more ...


# 1df8700a 20-Feb-2024 Olivier Certner <olce@FreeBSD.org>

PP mutexes: unlock: Reset inherited prio regardless of privileges

'uq_inherited_pri' contains the current priority inherited from Priority
Protection mutexes. If -1 is passed through 'm_ceilings[1]

PP mutexes: unlock: Reset inherited prio regardless of privileges

'uq_inherited_pri' contains the current priority inherited from Priority
Protection mutexes. If -1 is passed through 'm_ceilings[1]', meaning
that there are no such mutexes held anymore, this must be reflected into
it by setting it to PRI_MAX, regardless of whether the thread has
privilege to set realtime priorities (PRI_MAX is also obviously not
a realtime priority level). By contrast, it shall not be updated and
the computed 'new_inherited_pri' shall stay unused if the thread doesn't
have the ability to set a realtime priority, possibly keeping an older
such priority acquired previously.

Reviewed by: kib
Approved by: emaste (mentor)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43984

show more ...


# 3379d9b5 26-Dec-2023 Mark Johnston <markj@FreeBSD.org>

umtx: Check for errors from suword32()

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https

umtx: Check for errors from suword32()

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43144

show more ...


Revision tags: release/14.0.0
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

show more ...


# 93ca6ff2 15-Apr-2023 Konstantin Belousov <kib@FreeBSD.org>

umtx: allow to configure minimal timeout (in nanoseconds)

PR: 270785
Reviewed by: markj, mav
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org

umtx: allow to configure minimal timeout (in nanoseconds)

PR: 270785
Reviewed by: markj, mav
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39584

show more ...


Revision tags: release/13.2.0
# 5657f49e 20-Jan-2023 Konstantin Belousov <kib@FreeBSD.org>

kern_umtx.c do_wait(): correct confusing indent

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


Revision tags: release/12.4.0
# 0def80f1 03-Oct-2022 Hans Petter Selasky <hselasky@FreeBSD.org>

time(3): Align fast clock times to avoid firing multiple timers.

In non-periodic mode absolute timers fire at exactly the time given.
When specifying a fast clock, align the firing time so that less

time(3): Align fast clock times to avoid firing multiple timers.

In non-periodic mode absolute timers fire at exactly the time given.
When specifying a fast clock, align the firing time so that less
timer interrupt events are needed.

Reviewed by: rrs @
Differential Revision: https://reviews.freebsd.org/D36858
MFC after: 1 week
Sponsored by: NVIDIA Networking

show more ...


# 768f6373 26-Aug-2022 firk <firk@cantconnect.ru>

Fix compat10 semaphore interface race

Wrong has-waiters and missing unconditional _count==0 check may cause
infinite waiting with already non-zero count.
1) properly clear _has_waiters flag when wai

Fix compat10 semaphore interface race

Wrong has-waiters and missing unconditional _count==0 check may cause
infinite waiting with already non-zero count.
1) properly clear _has_waiters flag when waiting failed to start
2) always check _count before start waiting

PR: 265997
Reviewed by: kib
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36272

show more ...


# 630f633f 14-Jun-2022 Mark Johnston <markj@FreeBSD.org>

vm_object: Use the vm_object_(set|clear)_flag() helpers

... rather than setting and clearing flags inline. No functional change
intended.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: The

vm_object: Use the vm_object_(set|clear)_flag() helpers

... rather than setting and clearing flags inline. No functional change
intended.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35469

show more ...


# 31d1b816 28-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

sysent: Get rid of bogus sys/sysent.h include.

Where appropriate hide sysent.h under proper condition.

MFC after: 2 weeks


Revision tags: release/13.1.0
# 11a6ecd4 09-May-2022 Andrew Turner <andrew@FreeBSD.org>

Handle cas failure when the compare succeeds

When locking a priority inherit mutex we perform a compare and swap
operation to try and acquire the mutex. This may fail even when the
compare succeeds.

Handle cas failure when the compare succeeds

When locking a priority inherit mutex we perform a compare and swap
operation to try and acquire the mutex. This may fail even when the
compare succeeds.

Check and handle this case.

PR: 263825
Reviewed by: kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35150

show more ...


# 91e7bdcd 25-Apr-2022 Dmitry Chagin <dchagin@FreeBSD.org>

Add timespecvalid_interval macro and use it.

Reviewed by: jhb, imp (early rev)
Differential revision: https://reviews.freebsd.org/D34848
MFC after: 2 weeks


# fd6ca665 22-Mar-2022 Alexander Motin <mav@FreeBSD.org>

Fix umtxq_sleep() regression caused by 56070dd2e4d.

umtxq_requeue() moves the queue to a different hash chain and different
lock, so we can't rely on msleep_sbt() reacquiring the same old lock.
We h

Fix umtxq_sleep() regression caused by 56070dd2e4d.

umtxq_requeue() moves the queue to a different hash chain and different
lock, so we can't rely on msleep_sbt() reacquiring the same old lock.
We have to use PDROP and update the queue chain and so lock pointer.

PR: 262587
MFC after: 2 weeks

show more ...


# 56070dd2 04-Mar-2022 Alexander Motin <mav@FreeBSD.org>

Improve timeout precision of pthread_cond_timedwait().

This code was not touched when all other user-space sleep functions were
switched to sbintime_t and decoupled from hardclock. When it is possi

Improve timeout precision of pthread_cond_timedwait().

This code was not touched when all other user-space sleep functions were
switched to sbintime_t and decoupled from hardclock. When it is possible,
convert supplied times into sbinuptime to supply directly to msleep_sbt()
with C_ABSOLUTE. This provides the timeout resolution of few microseconds
instead of 2 milliseconds, plus avoids few clock reads and conversions.

Reviewed by: vangyzen
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D34163

show more ...


Revision tags: release/12.3.0
# 151ddfec 22-Nov-2021 Brooks Davis <brooks@FreeBSD.org>

freebsd32: add _'s to _umtx_(un)lock

This aligns with the default ABI's configuration.

Reviewed by: kib


12345678910>>...16