aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-10-02 05:17:28 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:15 -0400
commit2425c08b37244005ff221efe4957d8aaff18609c (patch)
tree488a298587acb651bd6964c0f9d53c9f48327362 /drivers/usb
parent43fa1adb9334bf4585cd53144eb5911488f85bc7 (diff)
[PATCH] usb: fixup usb so it uses struct pid
The problem with remembering a user space process by its pid is that it is possible that the process will exit, pid wrap around will occur. Converting to a struct pid avoid that problem, and paves the way for implementing a pid namespace. Also since usb is the only user of kill_proc_info_as_uid rename kill_proc_info_as_uid to kill_pid_info_as_uid and have the new version take a struct pid. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/devio.c10
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/core/usb.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index a94c63bef632..3f509beb88e4 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -65,7 +65,7 @@ DEFINE_MUTEX(usbfs_mutex);
65struct async { 65struct async {
66 struct list_head asynclist; 66 struct list_head asynclist;
67 struct dev_state *ps; 67 struct dev_state *ps;
68 pid_t pid; 68 struct pid *pid;
69 uid_t uid, euid; 69 uid_t uid, euid;
70 unsigned int signr; 70 unsigned int signr;
71 unsigned int ifnum; 71 unsigned int ifnum;
@@ -225,6 +225,7 @@ static struct async *alloc_async(unsigned int numisoframes)
225 225
226static void free_async(struct async *as) 226static void free_async(struct async *as)
227{ 227{
228 put_pid(as->pid);
228 kfree(as->urb->transfer_buffer); 229 kfree(as->urb->transfer_buffer);
229 kfree(as->urb->setup_packet); 230 kfree(as->urb->setup_packet);
230 usb_free_urb(as->urb); 231 usb_free_urb(as->urb);
@@ -317,7 +318,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
317 sinfo.si_errno = as->urb->status; 318 sinfo.si_errno = as->urb->status;
318 sinfo.si_code = SI_ASYNCIO; 319 sinfo.si_code = SI_ASYNCIO;
319 sinfo.si_addr = as->userurb; 320 sinfo.si_addr = as->userurb;
320 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 321 kill_pid_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
321 as->euid, as->secid); 322 as->euid, as->secid);
322 } 323 }
323 snoop(&urb->dev->dev, "urb complete\n"); 324 snoop(&urb->dev->dev, "urb complete\n");
@@ -573,7 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
573 INIT_LIST_HEAD(&ps->async_completed); 574 INIT_LIST_HEAD(&ps->async_completed);
574 init_waitqueue_head(&ps->wait); 575 init_waitqueue_head(&ps->wait);
575 ps->discsignr = 0; 576 ps->discsignr = 0;
576 ps->disc_pid = current->pid; 577 ps->disc_pid = get_pid(task_pid(current));
577 ps->disc_uid = current->uid; 578 ps->disc_uid = current->uid;
578 ps->disc_euid = current->euid; 579 ps->disc_euid = current->euid;
579 ps->disccontext = NULL; 580 ps->disccontext = NULL;
@@ -611,6 +612,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
611 usb_autosuspend_device(dev, 1); 612 usb_autosuspend_device(dev, 1);
612 usb_unlock_device(dev); 613 usb_unlock_device(dev);
613 usb_put_dev(dev); 614 usb_put_dev(dev);
615 put_pid(ps->disc_pid);
614 kfree(ps); 616 kfree(ps);
615 return 0; 617 return 0;
616} 618}
@@ -1063,7 +1065,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1063 as->userbuffer = NULL; 1065 as->userbuffer = NULL;
1064 as->signr = uurb->signr; 1066 as->signr = uurb->signr;
1065 as->ifnum = ifnum; 1067 as->ifnum = ifnum;
1066 as->pid = current->pid; 1068 as->pid = get_pid(task_pid(current));
1067 as->uid = current->uid; 1069 as->uid = current->uid;
1068 as->euid = current->euid; 1070 as->euid = current->euid;
1069 security_task_getsecid(current, &as->secid); 1071 security_task_getsecid(current, &as->secid);
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 7c77c2d8d300..b5d6a79af0be 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -699,7 +699,7 @@ static void usbfs_remove_device(struct usb_device *dev)
699 sinfo.si_errno = EPIPE; 699 sinfo.si_errno = EPIPE;
700 sinfo.si_code = SI_ASYNCIO; 700 sinfo.si_code = SI_ASYNCIO;
701 sinfo.si_addr = ds->disccontext; 701 sinfo.si_addr = ds->disccontext;
702 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid); 702 kill_pid_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid);
703 } 703 }
704 } 704 }
705} 705}
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index f69df137ec0e..13322e33f912 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -139,7 +139,7 @@ struct dev_state {
139 struct list_head async_completed; 139 struct list_head async_completed;
140 wait_queue_head_t wait; /* wake up if a request completed */ 140 wait_queue_head_t wait; /* wake up if a request completed */
141 unsigned int discsignr; 141 unsigned int discsignr;
142 pid_t disc_pid; 142 struct pid *disc_pid;
143 uid_t disc_uid, disc_euid; 143 uid_t disc_uid, disc_euid;
144 void __user *disccontext; 144 void __user *disccontext;
145 unsigned long ifclaimed; 145 unsigned long ifclaimed;