|
@@ -530,8 +530,25 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
|
|
|
return -EINVAL;
|
|
|
|
|
|
WARN_ON(!atomic_read(&pi_state->refcount));
|
|
|
- WARN_ON(pid && pi_state->owner &&
|
|
|
- pi_state->owner->pid != pid);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * When pi_state->owner is NULL then the owner died
|
|
|
+ * and another waiter is on the fly. pi_state->owner
|
|
|
+ * is fixed up by the task which acquires
|
|
|
+ * pi_state->rt_mutex.
|
|
|
+ *
|
|
|
+ * We do not check for pid == 0 which can happen when
|
|
|
+ * the owner died and robust_list_exit() cleared the
|
|
|
+ * TID.
|
|
|
+ */
|
|
|
+ if (pid && pi_state->owner) {
|
|
|
+ /*
|
|
|
+ * Bail out if user space manipulated the
|
|
|
+ * futex value.
|
|
|
+ */
|
|
|
+ if (pid != task_pid_vnr(pi_state->owner))
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
|
|
|
atomic_inc(&pi_state->refcount);
|
|
|
*ps = pi_state;
|