public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pid_ns: ensure pid is not freed during kill_pid_info_as_uid
@ 2011-09-26 15:18 Serge Hallyn
  2011-09-26 15:45 ` [PATCH 2/2] user namespace: usb: make usb urbs user namespace aware (v2) Serge Hallyn
  0 siblings, 1 reply; 6+ messages in thread
From: Serge Hallyn @ 2011-09-26 15:18 UTC (permalink / raw)
  To: Alan Stern
  Cc: Serge E. Hallyn, Greg KH, Oleg Nesterov, lkml, richard,
	Andrew Morton, Eric W. Biederman, Tejun Heo, linux-usb,
	Serge E. Hallyn

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.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
---
 drivers/usb/core/devio.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 37518df..eea53eb 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -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);
 }
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-27 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-26 15:18 [PATCH] pid_ns: ensure pid is not freed during kill_pid_info_as_uid Serge Hallyn
2011-09-26 15:45 ` [PATCH 2/2] user namespace: usb: make usb urbs user namespace aware (v2) Serge Hallyn
2011-09-26 23:45   ` Greg KH
2011-09-27 12:41     ` Serge E. Hallyn
2011-09-27 14:56       ` Greg KH
2011-09-27 15:18         ` Serge Hallyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox