Alexey Kuznetsov
778e9a9c3e
pi-futex: fix exit races and locking problems
...
1. New entries can be added to tsk->pi_state_list after task completed
exit_pi_state_list(). The result is memory leakage and deadlocks.
2. handle_mm_fault() is called under spinlock. The result is obvious.
3. results in self-inflicted deadlock inside glibc.
Sometimes futex_lock_pi returns -ESRCH, when it is not expected
and glibc enters to for(;;) sleep() to simulate deadlock. This problem
is quite obvious and I think the patch is right. Though it looks like
each "if" in futex_lock_pi() got some stupid special case "else if". :-)
4. sometimes futex_lock_pi() returns -EDEADLK,
when nobody has the lock. The reason is also obvious (see comment
in the patch), but correct fix is far beyond my comprehension.
I guess someone already saw this, the chunk:
if (rt_mutex_trylock(&q.pi_state->pi_mutex))
ret = 0;
is obviously from the same opera. But it does not work, because the
rtmutex is really taken at this point: wake_futex_pi() of previous
owner reassigned it to us. My fix works. But it looks very stupid.
I would think about removal of shift of ownership in wake_futex_pi()
and making all the work in context of process taking lock.
From: Thomas Gleixner <tglx@linutronix.de >
Fix 1) Avoid the tasklist lock variant of the exit race fix by adding
an additional state transition to the exit code.
This fixes also the issue, when a task with recursive segfaults
is not able to release the futexes.
Fix 2) Cleanup the lookup_pi_state() failure path and solve the -ESRCH
problem finally.
Fix 3) Solve the fixup_pi_state_owner() problem which needs to do the fixup
in the lock protected section by using the in_atomic userspace access
functions.
This removes also the ugly lock drop / unqueue inside of fixup_pi_state()
Fix 4) Fix a stale lock in the error path of futex_wake_pi()
Added some error checks for verification.
The -EDEADLK problem is solved by the rtmutex fixups.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Acked-by: Ingo Molnar <mingo@elte.hu >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Ulrich Drepper <drepper@redhat.com >
Cc: Eric Dumazet <dada1@cosmosbay.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2007-06-08 17:23:34 -07:00
..
2007-05-08 11:15:00 -07:00
2007-04-27 15:44:34 -03:00
2007-05-08 11:15:16 -07:00
2007-05-14 19:33:46 -04:00
2007-05-08 18:00:38 -07:00
2007-05-01 16:11:57 +02:00
2007-05-11 12:14:15 +01:00
2007-05-24 16:42:26 -07:00
2007-05-10 23:47:43 -07:00
2007-04-25 22:28:58 -07:00
2007-06-07 13:40:32 -07:00
2007-05-10 23:47:43 -07:00
2007-02-14 08:09:53 -08:00
2007-05-23 20:14:14 -07:00
2007-05-08 11:15:16 -07:00
2007-05-14 19:33:47 -04:00
2007-04-27 13:28:39 -07:00
2007-02-16 08:13:58 -08:00
2007-05-10 03:52:22 -04:00
2007-05-11 08:29:37 -07:00
2007-05-11 08:29:37 -07:00
2007-05-11 08:29:36 -07:00
2007-04-28 14:40:40 -04:00
2007-04-25 22:25:31 -07:00
2007-05-11 05:38:26 -04:00
2007-02-20 17:10:15 -08:00
2007-03-16 19:25:05 -07:00
2007-02-20 09:26:53 +00:00
2007-05-17 05:23:05 -07:00
2007-04-30 09:08:17 +02:00
2007-05-09 12:30:51 -07:00
2007-06-01 08:18:27 -07:00
2007-05-07 12:12:55 -07:00
2007-05-23 20:14:12 -07:00
2007-02-20 17:10:14 -08:00
2007-02-20 17:10:14 -08:00
2007-05-08 11:15:15 -07:00
2007-05-09 12:30:56 -07:00
2007-02-12 09:48:46 -08:00
2007-05-14 12:16:01 -07:00
2007-05-09 12:30:56 -07:00
2007-05-09 12:30:56 -07:00
2007-05-09 12:30:56 -07:00
2007-05-07 12:13:00 -07:00
2007-05-21 09:56:57 -07:00
2007-05-08 11:15:27 -07:00
2007-05-08 11:15:27 -07:00
2007-05-08 11:15:13 -07:00
2007-05-08 11:15:05 -07:00
2007-05-05 14:55:20 -07:00
2007-02-20 17:10:13 -08:00
2007-02-12 09:48:44 -08:00
2007-05-02 19:27:09 +02:00
2007-05-10 18:24:13 +02:00
2007-05-02 14:38:33 +10:00
2007-05-08 11:15:25 -07:00
2007-05-08 11:15:03 -07:00
2007-04-25 22:28:56 -07:00
2007-04-27 10:57:31 -07:00
2007-05-08 11:15:10 -07:00
2007-05-08 11:15:26 -07:00
2007-05-01 09:11:12 +01:00
2007-02-11 11:18:07 -08:00
2007-05-08 11:15:14 -07:00
2007-05-08 11:15:10 -07:00
2007-02-12 09:48:46 -08:00
2007-05-07 12:12:58 -07:00
2007-05-02 19:27:12 +02:00
2007-05-02 19:27:17 +02:00
2007-06-01 08:18:29 -07:00
2007-05-07 12:13:02 -07:00
2007-05-03 13:17:25 -07:00
2007-05-11 08:29:36 -07:00
2007-03-27 09:05:15 -07:00
2007-05-09 08:57:56 +02:00
2007-05-08 11:15:12 -07:00
2007-05-31 16:20:15 -04:00
2007-05-31 16:20:14 -04:00
2007-05-31 16:20:15 -04:00
2007-06-01 08:18:28 -07:00
2007-05-06 20:38:28 -04:00
2007-04-25 22:28:35 -07:00
2007-05-31 21:40:15 +02:00
2007-05-10 18:24:13 +02:00
2007-05-08 11:15:31 -07:00
2007-05-23 20:14:11 -07:00
2007-06-04 17:54:09 -07:00
2007-04-28 11:01:04 -04:00
2007-05-09 12:30:55 -07:00
2007-05-09 08:58:16 +02:00
2007-05-23 20:14:12 -07:00
2007-05-09 12:30:56 -07:00
2007-02-12 09:48:30 -08:00
2007-05-01 00:39:13 -04:00
2007-02-16 08:13:59 -08:00
2007-04-28 11:01:07 -04:00
2007-05-09 02:52:51 +02:00
2007-05-09 12:30:56 -07:00
2007-03-16 00:59:29 -04:00
2007-04-07 10:03:43 -07:00
2007-05-07 12:12:51 -07:00
2007-05-09 08:58:21 +02:00
2007-05-09 08:58:21 +02:00
2007-05-01 23:26:34 +02:00
2007-05-11 16:56:02 +02:00
2007-05-01 23:26:34 +02:00
2007-04-25 22:25:31 -07:00
2007-04-25 22:25:31 -07:00
2007-05-16 00:51:46 +02:00
2007-05-05 11:43:04 -07:00
2007-04-25 22:23:43 -07:00
2007-04-25 22:25:12 -07:00
2007-04-25 22:28:44 -07:00
2007-05-21 19:41:19 -04:00
2007-04-25 22:29:10 -07:00
2007-04-25 22:29:14 -07:00
2007-04-25 22:28:57 -07:00
2007-04-25 22:24:41 -07:00
2007-04-25 22:26:20 -07:00
2007-04-25 22:25:31 -07:00
2007-04-25 22:29:57 -07:00
2007-04-25 22:29:10 -07:00
2007-06-07 13:39:26 -07:00
2007-05-11 08:29:36 -07:00
2007-05-19 09:11:58 +02:00
2007-04-29 23:42:45 -04:00
2007-05-06 13:21:57 -07:00
2007-05-11 08:29:34 -07:00
2007-05-15 08:54:00 -07:00
2007-04-28 14:15:59 -04:00
2007-04-25 22:25:31 -07:00
2007-05-08 11:15:00 -07:00
2007-05-31 01:23:36 -07:00
2007-05-09 08:58:21 +02:00
2007-05-08 11:15:09 -07:00
2007-05-08 11:15:16 -07:00
2007-04-25 22:25:52 -07:00
2007-02-16 08:13:56 -08:00
2007-05-08 11:15:08 -07:00
2007-03-16 19:25:05 -07:00
2007-05-31 21:40:15 +02:00
2007-05-08 11:15:04 -07:00
2007-04-04 21:12:47 -07:00
2007-05-12 18:11:06 -07:00
2007-05-08 11:15:07 -07:00
2007-04-26 15:46:23 -07:00
2007-02-11 10:51:32 -08:00
2007-05-17 05:23:04 -07:00
2007-02-23 14:54:57 -08:00
2007-05-02 18:57:59 -07:00
2007-05-08 11:15:19 -07:00
2007-02-20 17:10:14 -08:00
2007-05-09 12:30:53 -07:00
2007-05-09 12:30:54 -07:00
2007-03-04 11:12:40 +02:00
2007-05-03 10:52:32 +03:00
2007-02-20 09:26:53 +00:00
2007-06-04 16:48:34 -04:00
2007-05-12 18:11:06 -07:00
2007-03-22 19:39:06 -07:00
2007-05-18 20:46:30 -07:00
2007-05-08 11:15:07 -07:00
2007-05-11 08:29:36 -07:00
2007-05-14 18:51:43 +02:00
2007-05-08 11:15:18 -07:00
2007-05-09 12:30:49 -07:00
2007-05-09 08:58:21 +02:00
2007-05-07 12:12:57 -07:00
2007-05-17 14:20:29 -07:00
2007-02-20 17:10:13 -08:00
2007-05-03 10:52:22 +03:00
2007-05-10 09:26:52 -07:00
2007-05-21 09:18:19 -07:00
2007-05-09 12:30:56 -07:00
2007-05-08 11:15:00 -07:00
2007-05-02 20:58:08 +02:00
2007-05-11 08:29:35 -07:00
2007-02-19 13:29:02 -08:00
2007-05-09 07:14:03 +02:00
2007-05-11 08:29:35 -07:00
2007-05-08 11:15:13 -07:00
2007-05-02 19:02:38 -07:00
2007-05-09 12:30:49 -07:00
2007-03-06 06:14:54 -05:00
2007-04-27 10:57:33 -07:00
2007-03-06 13:26:27 +01:00
2007-02-12 09:48:46 -08:00
2007-04-26 15:48:28 -07:00
2007-05-31 01:23:35 -07:00
2007-05-03 03:36:16 -07:00
2007-04-25 22:27:45 -07:00
2007-05-05 11:42:03 -07:00
2007-05-09 12:30:54 -07:00
2007-05-14 19:33:45 -04:00
2007-05-08 11:15:21 -07:00
2007-04-30 22:17:07 -07:00
2007-04-30 22:17:16 -07:00
2007-05-24 10:44:20 -04:00
2007-02-12 22:43:25 -08:00
2007-04-25 22:29:41 -07:00
2007-02-13 13:26:24 +01:00
2007-02-20 17:10:13 -08:00
2007-05-09 12:30:56 -07:00
2007-05-08 11:15:00 -07:00
2007-05-04 17:59:07 -07:00
2007-05-07 12:12:59 -07:00
2007-05-08 11:14:57 -07:00
2007-05-08 11:15:05 -07:00
2007-05-08 11:15:05 -07:00
2007-05-05 14:15:32 -07:00
2007-05-02 18:57:59 -07:00
2007-06-01 08:18:28 -07:00
2007-03-12 16:31:50 -07:00
2007-05-02 19:02:38 -07:00
2007-05-02 19:27:11 +02:00
2007-05-08 11:15:14 -07:00
2007-02-12 09:48:46 -08:00
2007-04-28 11:01:04 -04:00
2007-05-08 11:15:00 -07:00
2007-05-11 08:29:35 -07:00
2007-03-27 08:55:47 +02:00
2007-04-17 16:36:26 -07:00
2007-05-09 12:30:48 -07:00
2007-05-10 21:28:13 +10:00
2007-05-08 11:15:23 -07:00
2007-05-08 11:14:57 -07:00
2007-05-08 11:15:01 -07:00
2007-02-12 09:48:46 -08:00
2007-05-07 12:12:54 -07:00
2007-05-08 11:15:15 -07:00
2007-05-08 11:15:05 -07:00
2007-05-09 08:57:56 +02:00
2007-02-12 09:48:44 -08:00
2007-05-08 11:15:00 -07:00
2007-02-12 09:48:46 -08:00
2007-02-11 11:18:05 -08:00
2007-05-09 12:30:51 -07:00
2007-06-07 13:39:34 -07:00
2007-02-11 11:18:07 -08:00
2007-05-17 05:23:06 -07:00
2007-05-02 11:56:33 +01:00
2007-05-08 11:15:18 -07:00
2007-04-25 22:27:04 -07:00
2007-04-26 15:48:28 -07:00
2007-06-08 17:23:34 -07:00
2007-04-25 22:25:31 -07:00
2007-05-09 08:57:56 +02:00
2007-04-27 10:44:42 -07:00
2007-06-01 08:18:29 -07:00
2007-02-14 08:09:52 -08:00
2007-05-07 12:12:50 -07:00
2007-02-18 01:40:30 -05:00
2007-03-01 17:18:39 -08:00
2007-05-11 08:29:36 -07:00
2007-05-11 08:29:36 -07:00
2007-05-03 03:16:20 -07:00
2007-05-17 05:23:03 -07:00
2007-05-17 05:23:04 -07:00
2007-06-08 17:23:33 -07:00
2007-02-20 17:10:14 -08:00
2007-02-20 17:10:14 -08:00
2007-05-21 21:47:27 -07:00
2007-05-17 05:23:04 -07:00
2007-04-30 00:58:19 -07:00
2007-04-26 15:48:28 -07:00
2007-04-28 22:06:01 -04:00
2007-05-09 08:58:21 +02:00
2007-05-08 11:15:11 -07:00
2007-03-05 07:57:53 -08:00
2007-05-08 11:14:58 -07:00
2007-05-08 11:15:18 -07:00
2007-04-26 01:54:39 -07:00
2007-05-09 12:56:01 -07:00
2007-05-09 12:30:57 -07:00
2007-02-20 17:10:13 -08:00
2007-05-11 08:29:34 -07:00
2007-05-11 08:29:36 -07:00
2007-04-25 22:28:57 -07:00
2007-05-08 11:15:05 -07:00
2007-04-27 10:57:32 -07:00
2007-05-21 09:18:19 -07:00
2007-04-24 08:23:08 -07:00
2007-04-25 22:25:31 -07:00
2007-02-16 08:13:59 -08:00
2007-05-08 22:41:47 +02:00
2007-05-08 11:15:18 -07:00
2007-05-29 18:11:10 -07:00
2007-05-11 08:29:36 -07:00
2007-02-16 08:13:56 -08:00
2007-03-05 07:57:51 -08:00
2007-02-12 09:48:42 -08:00
2007-05-11 08:29:35 -07:00
2007-05-11 08:29:35 -07:00
2007-05-08 11:15:04 -07:00
2007-04-25 22:25:31 -07:00
2007-02-12 09:48:40 -08:00
2007-02-12 09:48:30 -08:00
2007-03-16 19:25:03 -07:00
2007-05-03 00:55:34 -04:00
2007-05-07 12:12:58 -07:00
2007-02-16 15:32:19 -08:00
2007-05-09 08:57:56 +02:00
2007-02-16 15:32:20 -08:00
2007-05-08 11:15:00 -07:00
2007-05-22 16:00:13 -03:00
2007-05-08 11:15:04 -07:00
2007-05-09 12:30:56 -07:00
2007-05-08 11:15:33 -07:00
2007-04-28 11:01:01 -04:00
2007-05-18 08:17:17 -07:00
2007-05-21 09:18:19 -07:00
2007-02-11 11:18:05 -08:00
2007-05-04 12:55:39 -07:00