[PATCH] SELinux: update USB code with new kill_proc_info_as_uid

This patch updates the USB core to save and pass the sending task secid when
sending signals upon AIO completion so that proper security checking can be
applied by security modules.

Signed-off-by: David Quigley <dpquigl@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
David Quigley 2006-06-30 01:55:48 -07:00 committed by Linus Torvalds
parent 8f95dc58d0
commit 7a01955f99
3 changed files with 7 additions and 2 deletions

View File

@ -47,6 +47,7 @@
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/security.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
@ -68,6 +69,7 @@ struct async {
void __user *userbuffer; void __user *userbuffer;
void __user *userurb; void __user *userurb;
struct urb *urb; struct urb *urb;
u32 secid;
}; };
static int usbfs_snoop = 0; static int usbfs_snoop = 0;
@ -312,7 +314,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
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_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
as->euid); as->euid, as->secid);
} }
snoop(&urb->dev->dev, "urb complete\n"); snoop(&urb->dev->dev, "urb complete\n");
snoop_urb(urb, as->userurb); snoop_urb(urb, as->userurb);
@ -572,6 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
ps->disc_euid = current->euid; ps->disc_euid = current->euid;
ps->disccontext = NULL; ps->disccontext = NULL;
ps->ifclaimed = 0; ps->ifclaimed = 0;
security_task_getsecid(current, &ps->secid);
wmb(); wmb();
list_add_tail(&ps->list, &dev->filelist); list_add_tail(&ps->list, &dev->filelist);
file->private_data = ps; file->private_data = ps;
@ -1053,6 +1056,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
as->pid = current->pid; as->pid = current->pid;
as->uid = current->uid; as->uid = current->uid;
as->euid = current->euid; as->euid = current->euid;
security_task_getsecid(current, &as->secid);
if (!(uurb->endpoint & USB_DIR_IN)) { if (!(uurb->endpoint & USB_DIR_IN)) {
if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) { if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) {
free_async(as); free_async(as);

View File

@ -700,7 +700,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); kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid);
} }
} }
} }

View File

@ -80,6 +80,7 @@ struct dev_state {
uid_t disc_uid, disc_euid; uid_t disc_uid, disc_euid;
void __user *disccontext; void __user *disccontext;
unsigned long ifclaimed; unsigned long ifclaimed;
u32 secid;
}; };
/* internal notify stuff */ /* internal notify stuff */