Futex II: Copy-from-user can fail.
PATCH 1/1 Futex II: Copy-from-user can fail.
OK, so AFAICT copy_from_user can fail, so shouldn't BUG.
Name: Copy-from-user FUTEX bugfix
Author: Rusty Russell
Status: Tested on 2.5.20
D: This patch handles the case where copy_from_user fails (it could
D: have been unmapped from this address space by another thread).
kernel/futex.c +6 -4
@@ -155,13 +155,14 @@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);
@@ -174,6 +175,7 @@ goto out; } out: +set_current_state (TASK_RUNNING );/* Were we woken up anyway? */ if (!unqueue_me (&q))return 0 ;
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.