USB: pid_ns: ensure pid is not freed during kill_pid_info_as_uid
authorSerge Hallyn <serge.hallyn@canonical.com>
Mon, 26 Sep 2011 15:18:29 +0000 (10:18 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 26 Sep 2011 23:12:26 +0000 (16:12 -0700)
Alan Stern points out that after spin_unlock(&ps->lock) there is no
guarantee that ps->pid won't be freed.  Since kill_pid_info_as_uid() is
called after the spin_unlock(), the pid passed to it must be pinned.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/devio.c

index 37518dfdeb987188089eb43c3147417ce14615a9..eea53ebe670636db8f1957261bbfd36b696913de 100644 (file)
@@ -407,7 +407,7 @@ static void async_completed(struct urb *urb)
                sinfo.si_errno = as->status;
                sinfo.si_code = SI_ASYNCIO;
                sinfo.si_addr = as->userurb;
-               pid = as->pid;
+               pid = get_pid(as->pid);
                uid = as->uid;
                euid = as->euid;
                secid = as->secid;
@@ -422,9 +422,11 @@ static void async_completed(struct urb *urb)
                cancel_bulk_urbs(ps, as->bulk_addr);
        spin_unlock(&ps->lock);
 
-       if (signr)
+       if (signr) {
                kill_pid_info_as_uid(sinfo.si_signo, &sinfo, pid, uid,
                                      euid, secid);
+               put_pid(pid);
+       }
 
        wake_up(&ps->wait);
 }