cobalt/synch: Do not drop PP on xnsynch_release if it wasn't committed
RFC PATCH 1/1 cobalt/synch: Do not drop PP on xnsynch_release if it wasn't committed
We must not try to drop the prio ceiling in the kernel if it wasn't committed yet. That could easily happen when using a prio-ceiling mutex to wait on a cond-var.
This is not the most robust solution as it bases the decision on userspace controlled state which could be corrupted.
---
As written above, I'm wondering if we shouldn't mirror the state into kernel space. Or do we have it somewhere already?
Also, could you have a second look at the whole PP thing Philippe. Are there more imbalances possible? I'll think through that again as well. TIA!
Test case will follow tomorrow (likely).
kernel/cobalt/synch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/cobalt/synch.c +3 -2
@@ -942,12 +942,13 @@ bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr)*/ xnlock_get_irqsave (&nklock, s); -if (synch->status &XNSYNCH_PP ) { + h =atomic_cmpxchg (lockp, currh,XN_NO_HANDLE ); + +if (h &XNSYNCH_FLCEIL ) {clear_pp_boost (synch, curr); need_resched = true; } - h =atomic_cmpxchg (lockp, currh,XN_NO_HANDLE );if ((h & ~XNSYNCH_FLCEIL ) != currh)/* FLCLAIM set, synch is contended. */ need_resched =transfer_ownership (synch, curr);
Signature · 1 line
2.13.6
Quoted 7 lines · Jan Kiszka
We must not try to drop the prio ceiling in the kernel if it wasn't committed yet. That could easily happen when using a prio-ceiling mutex to wait on a cond-var.
This is not the most robust solution as it bases the decision on userspace controlled state which could be corrupted.
The same issue applies to all *acquire() forms.
Quoted 4 lines
As written above, I'm wondering if we shouldn't mirror the state into kernel space. Or do we have it somewhere already?
XNSYNCH_CEILING in this context, since ceil_owner_priority() raises it when committing the boost.
Quoted 2 lines
Also, could you have a second look at the whole PP thing Philippe. Are there more imbalances possible?
Unlikely in kernel space where there is a single release point. However the tricky part is about getting that state in sync with the syscall-less fast path in userland.
Quoted 3 lines
I'll think through that again as well.
TIA!
Ok, I'll have a look when I'm back on-line in two weeks.
Signature · 1 line
Philippe.