Skip to content
  • Sebastian Andrzej Siewior's avatar
    Revert "kmod: fix race in usermodehelper code" · 95e0d86b
    Sebastian Andrzej Siewior authored
    This reverts commit c02e3f36
    
     ("kmod: fix race in usermodehelper code")
    
    The patch is wrong.  UMH_WAIT_EXEC is called with VFORK what ensures
    that the child finishes prior returing back to the parent.  No race.
    
    In fact, the patch makes it even worse because it does the thing it
    claims not do:
    
     - It calls ->complete() on UMH_WAIT_EXEC
    
     - the complete() callback may de-allocated subinfo as seen in the
       following call chain:
    
        [<c009f904>] (__link_path_walk+0x20/0xeb4) from [<c00a094c>] (path_walk+0x48/0x94)
        [<c00a094c>] (path_walk+0x48/0x94) from [<c00a0a34>] (do_path_lookup+0x24/0x4c)
        [<c00a0a34>] (do_path_lookup+0x24/0x4c) from [<c00a158c>] (do_filp_open+0xa4/0x83c)
        [<c00a158c>] (do_filp_open+0xa4/0x83c) from [<c009ba90>] (open_exec+0x24/0xe0)
        [<c009ba90>] (open_exec+0x24/0xe0) from [<c009bfa8>] (do_execve+0x7c/0x2e4)
        [<c009bfa8>] (do_execve+0x7c/0x2e4) from [<c0026a80>] (kernel_execve+0x34/0x80)
        [<c0026a80>] (kernel_execve+0x34/0x80) from [<c004b514>] (____call_usermodehelper+0x130/0x148)
        [<c004b514>] (____call_usermodehelper+0x130/0x148) from [<c0024858>] (kernel_thread_exit+0x0/0x8)
    
       and the path pointer was NULL.  Good that ARM's kernel_execve()
       doesn't check the pointer for NULL or else I wouldn't notice it.
    
    The only race there might be is with UMH_NO_WAIT but it is too late for
    me to investigate it now.  UMH_WAIT_PROC could probably also use VFORK
    and we could save one exec.  So the only race I see is with UMH_NO_WAIT
    and recent scheduler changes where the child does not always run first
    might have trigger here something but as I said, it is late....
    
    Signed-off-by: default avatarSebastian Andrzej Siewior <sebastian@breakpoint.cc>
    Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    95e0d86b