public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [CHECKER] Is this a bug?
@ 2001-11-01 19:13 Ken Ashcraft
  2001-11-01 22:42 ` Andreas Dilger
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Ashcraft @ 2001-11-01 19:13 UTC (permalink / raw)
  To: linux-kernel

Hi,

I'm trying to figure out if the following is a bug, but I don't understand
well enough how files work.  This type of bug would be a security hole.
The user length "cmd" gets passed in to the sys_ioctl call. From there, if
it does not match one of the case statements, it is passed to a function
pointer.  Here is where I'm hung up: I think a potential function for that
function pointer is ip2_ipl_ioctl-- I think this because it is assigned to
the ioctl field of a file_operations struct at one place in the code:

/* 2.4.12/drivers/char/ip2main.c */
/* This is the driver descriptor for the ip2ipl device, which is used to
 * download the loadware to the boards.
 */
static struct file_operations ip2_ipl = {
	owner:		THIS_MODULE,
	read:		ip2_ipl_read,
	write:		ip2_ipl_write,
	ioctl:		ip2_ipl_ioctl,
	open:		ip2_ipl_open,
};

ip2_ipl_ioctl does not treat its command argument safely as shown below.

Here are the excerpts from the code:

/* 2.4.9-ac9/fs/ioctl.c:sys_ioctl */
asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long
arg)
{
	...
	switch (cmd) {
	...
	default:
		error = -ENOTTY;
		if (S_ISREG(filp->f_dentry->d_inode->i_mode))
			error = file_ioctl(filp, cmd, arg);
		else if (filp->f_op && filp->f_op->ioctl)
Call --->
			error = filp->f_op->ioctl(filp->f_dentry->d_inode,
filp, cmd, arg);
	}
}
/* 2.4.9-ac9/drivers/char/ip2main.c */
static int
ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG
arg )
{
	...
	switch ( iplminor ) {
	...
	case 13:
		switch ( cmd ) {
		...
		default:
Error--->
			pCh = DevTable[cmd];
			if ( pCh )
			{
				COPY_TO_USER(rc, (char*)arg, (char*)pCh,
sizeof(i2ChanStr) );
			}
		}
	}
}


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

end of thread, other threads:[~2001-11-02  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.l396uov.18jgog6@ifi.uio.no>
     [not found] ` <fa.dvj9vsv.1b4k8ip@ifi.uio.no>
2001-11-02 10:09   ` [CHECKER] Is this a bug? Giacomo Catenazzi
2001-11-01 19:13 Ken Ashcraft
2001-11-01 22:42 ` Andreas Dilger

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