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

(cherry picked from commit 1df8700aa6)

Approved by:            emaste (mentor)
This commit is contained in:
Olivier Certner 2024-02-20 14:52:40 +01:00
parent e121845426
commit eded8fea5c
No known key found for this signature in database
GPG key ID: 8CA13040971E2627

View file

@ -2684,7 +2684,8 @@ do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags, bool rb)
struct umtx_q *uq, *uq2;
struct umtx_pi *pi;
uint32_t id, owner, rceiling;
int error, pri, new_inherited_pri, su;
int error, pri, new_inherited_pri;
bool su;
id = td->td_tid;
uq = td->td_umtxq;
@ -2739,7 +2740,7 @@ do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags, bool rb)
error = EFAULT;
else {
mtx_lock(&umtx_lock);
if (su != 0)
if (su || new_inherited_pri == PRI_MAX)
uq->uq_inherited_pri = new_inherited_pri;
pri = PRI_MAX;
TAILQ_FOREACH(pi, &uq->uq_pi_contested, pi_link) {