Files
rockchip-kernel/include/linux
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
..
2006-09-26 17:40:24 -04:00
2007-05-14 19:33:46 -04:00
2007-05-01 16:11:57 +02:00
2007-05-08 11:15:16 -07:00
2007-05-14 19:33:47 -04:00
2006-12-04 02:00:22 -05:00
2006-12-02 21:22:55 -08:00
2006-12-02 21:22:55 -08:00
2007-05-11 05:38:26 -04:00
2007-02-20 17:10:15 -08:00
2006-12-08 08:28:39 -08:00
2007-05-09 12:30:51 -07:00
2006-12-07 08:39:20 -08:00
2007-05-07 12:12:55 -07:00
2006-12-08 08:28:39 -08:00
2007-05-23 20:14:12 -07:00
2007-01-30 08:26:45 -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-05-07 12:13:00 -07:00
2007-05-21 09:56:57 -07:00
2007-05-10 18:24:13 +02:00
2007-05-08 11:15:25 -07:00
2007-04-27 10:57:31 -07:00
2006-12-07 08:39:25 -08:00
2007-05-08 11:15:26 -07:00
2007-05-01 09:11:12 +01:00
2006-07-03 19:44:51 -07:00
2007-02-09 17:39:36 -05:00
2007-02-11 11:18:07 -08:00
2007-05-07 12:12:58 -07:00
2007-06-01 08:18:29 -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-31 16:20:15 -04:00
2007-05-31 16:20:14 -04:00
2007-05-06 20:38:28 -04:00
2006-09-22 15:18:47 -07:00
2007-06-04 17:54:09 -07:00
2006-12-07 08:39:32 -08:00
2007-05-09 12:30:55 -07:00
2006-10-02 07:57:12 -07:00
2007-04-28 11:01:07 -04:00
2007-03-16 00:59:29 -04:00
2007-04-07 10:03:43 -07:00
2007-05-11 16:56:02 +02:00
2006-12-10 21:21:29 +01:00
2007-05-01 23:26:34 +02:00
2007-05-16 00:51:46 +02:00
2007-04-25 22:29:10 -07:00
2007-04-25 22:24:41 -07:00
2007-04-25 22:29:10 -07:00
2006-09-28 18:02:29 -07:00
2007-05-11 08:29:36 -07:00
2007-05-11 08:29:34 -07:00
2007-05-15 08:54:00 -07:00
2006-10-10 15:37:22 -07:00
2006-08-21 10:02:50 +02:00
2006-12-02 21:21:21 -08:00
2006-12-07 08:39:47 -08:00
2006-12-07 08:39:47 -08:00
2006-12-07 08:39:47 -08:00
2006-10-04 00:31:09 -07:00
2007-05-08 11:15:09 -07:00
2006-06-21 12:40:49 -07:00
2006-12-08 08:28:57 -08:00
2006-11-30 05:24:39 +01:00
2007-04-25 22:25:52 -07:00
2007-05-09 12:30:53 -07:00
2007-05-09 12:30:54 -07:00
2007-05-03 10:52:32 +03:00
2007-06-04 16:48:34 -04:00
2006-07-31 15:44:29 -04:00
2007-05-18 20:46:30 -07:00
2006-06-05 12:29:17 -07:00
2007-05-08 11:15:18 -07:00
2007-05-09 12:30:49 -07:00
2007-05-03 10:52:22 +03:00
2007-05-21 09:18:19 -07:00
2006-11-30 04:40:22 +01:00
2006-09-28 18:02:22 -07:00
2007-01-23 00:34:54 -05:00
2007-05-09 12:30:54 -07:00
2006-08-27 11:01:32 -07:00
2007-05-04 17:59:07 -07:00
2007-05-07 12:12:59 -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-03-12 16:31:50 -07:00
2007-05-08 11:15:14 -07:00
2007-03-27 08:55:47 +02:00
2007-04-17 16:36:26 -07:00
2007-05-08 11:14:57 -07:00
2006-12-04 02:00:36 -05:00
2006-10-03 23:01:26 +02:00
2007-01-11 18:18:21 -08:00
2007-05-07 12:12:54 -07:00
2007-05-09 08:57:56 +02:00
2006-06-25 10:01:06 -07:00
2006-06-25 10:01:06 -07:00
2006-09-26 08:49:04 -07:00
2007-06-07 13:39:34 -07:00
2007-05-17 05:23:06 -07:00
2006-06-25 10:01:14 -07:00
2007-05-08 11:15:18 -07:00
2007-05-09 08:57:56 +02:00
2006-12-07 08:39:35 -08:00
2007-05-07 12:12:50 -07: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-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-08 11:14:58 -07:00
2007-05-08 11:15:18 -07:00
2006-10-01 00:39:18 -07:00
2007-05-09 12:30:57 -07:00
2007-02-11 10:51:18 -08: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
2006-11-30 05:32:19 +01:00
2007-05-08 11:15:18 -07:00
2007-05-11 08:29:36 -07:00
2007-02-16 08:13:56 -08:00
2006-12-02 21:21:08 -08:00
2007-03-05 07:57:51 -08:00
2006-09-28 17:53:59 -07:00
2007-05-11 08:29:35 -07:00
2007-05-11 08:29:35 -07:00
2007-05-03 00:55:34 -04:00
2006-12-15 08:47:51 -08:00
2007-05-07 12:12:58 -07:00
2007-05-09 08:57:56 +02:00
2006-10-01 00:39:19 -07:00
2007-05-09 12:30:56 -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