|
@@ -910,10 +910,18 @@ retry:
|
|
|
return -EDEADLK;
|
|
|
|
|
|
/*
|
|
|
- * Surprise - we got the lock. Just return to userspace:
|
|
|
+ * Surprise - we got the lock, but we do not trust user space at all.
|
|
|
*/
|
|
|
- if (unlikely(!curval))
|
|
|
- return 1;
|
|
|
+ if (unlikely(!curval)) {
|
|
|
+ /*
|
|
|
+ * We verify whether there is kernel state for this
|
|
|
+ * futex. If not, we can safely assume, that the 0 ->
|
|
|
+ * TID transition is correct. If state exists, we do
|
|
|
+ * not bother to fixup the user space state as it was
|
|
|
+ * corrupted already.
|
|
|
+ */
|
|
|
+ return futex_top_waiter(hb, key) ? -EINVAL : 1;
|
|
|
+ }
|
|
|
|
|
|
uval = curval;
|
|
|
|