Skip to content

Commit

Permalink
[PATCH] ide: add sanity checking to ide taskfile ioctl
Browse files Browse the repository at this point in the history
Without this the user can feed in bogus values and get very bogus
results. Security impact is minimal as this ioctl isn't available to
unpriviledged processes anyway.

Reported to the l/k list and found with an auditing tool.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Oct 16, 2006
1 parent 9d90daf commit 3a42bb2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/ide/ide-taskfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
task_ioreg_t *hobsptr = args.hobRegister;
int err = 0;
int tasksize = sizeof(struct ide_task_request_s);
int taskin = 0;
int taskout = 0;
unsigned int taskin = 0;
unsigned int taskout = 0;
u8 io_32bit = drive->io_32bit;
char __user *buf = (char __user *)arg;

Expand All @@ -538,8 +538,13 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
return -EFAULT;
}

taskout = (int) req_task->out_size;
taskin = (int) req_task->in_size;
taskout = req_task->out_size;
taskin = req_task->in_size;

if (taskin > 65536 || taskout > 65536) {
err = -EINVAL;
goto abort;
}

if (taskout) {
int outtotal = tasksize;
Expand Down

0 comments on commit 3a42bb2

Please sign in to comment.