]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Futex II: Copy-from-user can fail.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 6 Jun 2002 02:25:39 +0000 (19:25 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 6 Jun 2002 02:25:39 +0000 (19:25 -0700)
This patch handles the case where copy_from_user fails (it could
have been unmapped from this address space by another thread).

kernel/futex.c

index ed03e2b73787e9936db7e53231ba76f1b2911540..029c902869f4c309e14c3de9b11d9e4e6e6e2827 100644 (file)
@@ -150,13 +150,14 @@ static int futex_wait(struct list_head *head,
        set_current_state(TASK_INTERRUPTIBLE);
        queue_me(head, &q, page, offset);
 
-       /* Page is pinned, can't fail */
-       if (get_user(curval, uaddr) != 0)
-               BUG();
+       /* Page is pinned, but may no longer be in this address space. */
+       if (get_user(curval, uaddr) != 0) {
+               ret = -EFAULT;
+               goto out;
+       }
 
        if (curval != val) {
                ret = -EWOULDBLOCK;
-               set_current_state(TASK_RUNNING);
                goto out;
        }
        time = schedule_timeout(time);
@@ -169,6 +170,7 @@ static int futex_wait(struct list_head *head,
                goto out;
        }
  out:
+       set_current_state(TASK_RUNNING);
        /* Were we woken up anyway? */
        if (!unqueue_me(&q))
                return 0;