aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/usb/core/devio.c10
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/core/usb.h2
-rw-r--r--include/linux/sched.h2
-rw-r--r--kernel/signal.c8
5 files changed, 13 insertions, 11 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;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3b7c99265ace..a7fff3304bd6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1269,12 +1269,12 @@ extern int force_sig_info(int, struct siginfo *, struct task_struct *);
1269extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); 1269extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
1270extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); 1270extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
1271extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid); 1271extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
1272extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
1272extern int kill_pgrp(struct pid *pid, int sig, int priv); 1273extern int kill_pgrp(struct pid *pid, int sig, int priv);
1273extern int kill_pid(struct pid *pid, int sig, int priv); 1274extern int kill_pid(struct pid *pid, int sig, int priv);
1274extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); 1275extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
1275extern int kill_pg_info(int, struct siginfo *, pid_t); 1276extern int kill_pg_info(int, struct siginfo *, pid_t);
1276extern int kill_proc_info(int, struct siginfo *, pid_t); 1277extern int kill_proc_info(int, struct siginfo *, pid_t);
1277extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t, u32);
1278extern void do_notify_parent(struct task_struct *, int); 1278extern void do_notify_parent(struct task_struct *, int);
1279extern void force_sig(int, struct task_struct *); 1279extern void force_sig(int, struct task_struct *);
1280extern void force_sig_specific(int, struct task_struct *); 1280extern void force_sig_specific(int, struct task_struct *);
diff --git a/kernel/signal.c b/kernel/signal.c
index 5230ddcb1757..7ed8d5304bec 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1136,8 +1136,8 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1136 return error; 1136 return error;
1137} 1137}
1138 1138
1139/* like kill_proc_info(), but doesn't use uid/euid of "current" */ 1139/* like kill_pid_info(), but doesn't use uid/euid of "current" */
1140int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid, 1140int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
1141 uid_t uid, uid_t euid, u32 secid) 1141 uid_t uid, uid_t euid, u32 secid)
1142{ 1142{
1143 int ret = -EINVAL; 1143 int ret = -EINVAL;
@@ -1147,7 +1147,7 @@ int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid,
1147 return ret; 1147 return ret;
1148 1148
1149 read_lock(&tasklist_lock); 1149 read_lock(&tasklist_lock);
1150 p = find_task_by_pid(pid); 1150 p = pid_task(pid, PIDTYPE_PID);
1151 if (!p) { 1151 if (!p) {
1152 ret = -ESRCH; 1152 ret = -ESRCH;
1153 goto out_unlock; 1153 goto out_unlock;
@@ -1171,7 +1171,7 @@ out_unlock:
1171 read_unlock(&tasklist_lock); 1171 read_unlock(&tasklist_lock);
1172 return ret; 1172 return ret;
1173} 1173}
1174EXPORT_SYMBOL_GPL(kill_proc_info_as_uid); 1174EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);
1175 1175
1176/* 1176/*
1177 * kill_something_info() interprets pid in interesting ways just like kill(2). 1177 * kill_something_info() interprets pid in interesting ways just like kill(2).