The branch stable/14 has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=eded8fea5c3a7ef7aafb5755c523a40dd7fce20e

commit eded8fea5c3a7ef7aafb5755c523a40dd7fce20e
Author:     Olivier Certner <[email protected]>
AuthorDate: 2024-02-20 13:52:40 +0000
Commit:     Olivier Certner <[email protected]>
CommitDate: 2024-05-09 13:26:16 +0000

    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 1df8700aa6cff7c759e90f7e507de4b8714435a4)
    
    Approved by:            emaste (mentor)
---
 sys/kern/kern_umtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 57ff74f5421e..9c7225863bb1 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -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) {

Reply via email to