Skip to content

Commit

Permalink
USB: pid_ns: ensure pid is not freed during kill_pid_info_as_uid
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Serge Hallyn <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
hallyn authored and gregkh committed Sep 26, 2011
1 parent 5c12e78 commit aec01c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit aec01c5

Please sign in to comment.