]> err.no Git - linux-2.6/commitdiff
[PATCH] uml: fix exitcall ordering bug
authorJeff Dike <jdike@addtoit.com>
Mon, 10 Jul 2006 11:45:11 +0000 (04:45 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 10 Jul 2006 20:24:24 +0000 (13:24 -0700)
This fixes an exitcall ordering bug - calls to ignore_sigio_fd can come from
exitcalls that come after the sigio thread has been killed.  This would cause
shutdown to hang or crash.

Fixed by having ignore_sigio_fd check that the thread is present before trying
to communicate with it.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/um/os-Linux/sigio.c

index 0d2422a7d72cd0b564ae0cebfd4a997c481be150..d22623e8fcedfad55fe31a4f2ee51f02e59683ca 100644 (file)
@@ -191,6 +191,13 @@ int ignore_sigio_fd(int fd)
        struct pollfd *p;
        int err = 0, i, n = 0;
 
+       /* This is called from exitcalls elsewhere in UML - if
+        * sigio_cleanup has already run, then update_thread will hang
+        * or fail because the thread is no longer running.
+        */
+       if(write_sigio_pid == -1)
+               return -EIO;
+
        sigio_lock();
        for(i = 0; i < current_poll.used; i++){
                if(current_poll.poll[i].fd == fd) break;
@@ -215,7 +222,7 @@ int ignore_sigio_fd(int fd)
        update_thread();
  out:
        sigio_unlock();
-       return(err);
+       return err;
 }
 
 static struct pollfd *setup_initial_poll(int fd)