Commit 2425c08b authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[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: default avatarEric W. Biederman <ebiederm@xmission.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 43fa1adb
...@@ -65,7 +65,7 @@ DEFINE_MUTEX(usbfs_mutex); ...@@ -65,7 +65,7 @@ DEFINE_MUTEX(usbfs_mutex);
struct async { struct async {
struct list_head asynclist; struct list_head asynclist;
struct dev_state *ps; struct dev_state *ps;
pid_t pid; struct pid *pid;
uid_t uid, euid; uid_t uid, euid;
unsigned int signr; unsigned int signr;
unsigned int ifnum; unsigned int ifnum;
...@@ -225,6 +225,7 @@ static struct async *alloc_async(unsigned int numisoframes) ...@@ -225,6 +225,7 @@ static struct async *alloc_async(unsigned int numisoframes)
static void free_async(struct async *as) static void free_async(struct async *as)
{ {
put_pid(as->pid);
kfree(as->urb->transfer_buffer); kfree(as->urb->transfer_buffer);
kfree(as->urb->setup_packet); kfree(as->urb->setup_packet);
usb_free_urb(as->urb); usb_free_urb(as->urb);
...@@ -317,7 +318,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs) ...@@ -317,7 +318,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
sinfo.si_errno = as->urb->status; sinfo.si_errno = as->urb->status;
sinfo.si_code = SI_ASYNCIO; sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = as->userurb; sinfo.si_addr = as->userurb;
kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, kill_pid_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
as->euid, as->secid); as->euid, as->secid);
} }
snoop(&urb->dev->dev, "urb complete\n"); snoop(&urb->dev->dev, "urb complete\n");
...@@ -573,7 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file) ...@@ -573,7 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
INIT_LIST_HEAD(&ps->async_completed); INIT_LIST_HEAD(&ps->async_completed);
init_waitqueue_head(&ps->wait); init_waitqueue_head(&ps->wait);
ps->discsignr = 0; ps->discsignr = 0;
ps->disc_pid = current->pid; ps->disc_pid = get_pid(task_pid(current));
ps->disc_uid = current->uid; ps->disc_uid = current->uid;
ps->disc_euid = current->euid; ps->disc_euid = current->euid;
ps->disccontext = NULL; ps->disccontext = NULL;
...@@ -611,6 +612,7 @@ static int usbdev_release(struct inode *inode, struct file *file) ...@@ -611,6 +612,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
usb_autosuspend_device(dev, 1); usb_autosuspend_device(dev, 1);
usb_unlock_device(dev); usb_unlock_device(dev);
usb_put_dev(dev); usb_put_dev(dev);
put_pid(ps->disc_pid);
kfree(ps); kfree(ps);
return 0; return 0;
} }
...@@ -1063,7 +1065,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1063,7 +1065,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
as->userbuffer = NULL; as->userbuffer = NULL;
as->signr = uurb->signr; as->signr = uurb->signr;
as->ifnum = ifnum; as->ifnum = ifnum;
as->pid = current->pid; as->pid = get_pid(task_pid(current));
as->uid = current->uid; as->uid = current->uid;
as->euid = current->euid; as->euid = current->euid;
security_task_getsecid(current, &as->secid); security_task_getsecid(current, &as->secid);
......
...@@ -699,7 +699,7 @@ static void usbfs_remove_device(struct usb_device *dev) ...@@ -699,7 +699,7 @@ static void usbfs_remove_device(struct usb_device *dev)
sinfo.si_errno = EPIPE; sinfo.si_errno = EPIPE;
sinfo.si_code = SI_ASYNCIO; sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = ds->disccontext; sinfo.si_addr = ds->disccontext;
kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid); kill_pid_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid);
} }
} }
} }
......
...@@ -139,7 +139,7 @@ struct dev_state { ...@@ -139,7 +139,7 @@ struct dev_state {
struct list_head async_completed; struct list_head async_completed;
wait_queue_head_t wait; /* wake up if a request completed */ wait_queue_head_t wait; /* wake up if a request completed */
unsigned int discsignr; unsigned int discsignr;
pid_t disc_pid; struct pid *disc_pid;
uid_t disc_uid, disc_euid; uid_t disc_uid, disc_euid;
void __user *disccontext; void __user *disccontext;
unsigned long ifclaimed; unsigned long ifclaimed;
......
...@@ -1269,12 +1269,12 @@ extern int force_sig_info(int, struct siginfo *, struct task_struct *); ...@@ -1269,12 +1269,12 @@ extern int force_sig_info(int, struct siginfo *, struct task_struct *);
extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp); extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid); extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
extern int kill_pgrp(struct pid *pid, int sig, int priv); extern int kill_pgrp(struct pid *pid, int sig, int priv);
extern int kill_pid(struct pid *pid, int sig, int priv); extern int kill_pid(struct pid *pid, int sig, int priv);
extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
extern int kill_pg_info(int, struct siginfo *, pid_t); extern int kill_pg_info(int, struct siginfo *, pid_t);
extern int kill_proc_info(int, struct siginfo *, pid_t); extern int kill_proc_info(int, struct siginfo *, pid_t);
extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t, u32);
extern void do_notify_parent(struct task_struct *, int); extern void do_notify_parent(struct task_struct *, int);
extern void force_sig(int, struct task_struct *); extern void force_sig(int, struct task_struct *);
extern void force_sig_specific(int, struct task_struct *); extern void force_sig_specific(int, struct task_struct *);
......
...@@ -1136,8 +1136,8 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid) ...@@ -1136,8 +1136,8 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid)
return error; return error;
} }
/* like kill_proc_info(), but doesn't use uid/euid of "current" */ /* like kill_pid_info(), but doesn't use uid/euid of "current" */
int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid, int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
uid_t uid, uid_t euid, u32 secid) uid_t uid, uid_t euid, u32 secid)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -1147,7 +1147,7 @@ int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid, ...@@ -1147,7 +1147,7 @@ int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid,
return ret; return ret;
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
p = find_task_by_pid(pid); p = pid_task(pid, PIDTYPE_PID);
if (!p) { if (!p) {
ret = -ESRCH; ret = -ESRCH;
goto out_unlock; goto out_unlock;
...@@ -1171,7 +1171,7 @@ out_unlock: ...@@ -1171,7 +1171,7 @@ out_unlock:
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(kill_proc_info_as_uid); EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);
/* /*
* kill_something_info() interprets pid in interesting ways just like kill(2). * kill_something_info() interprets pid in interesting ways just like kill(2).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment