Skip to content

Commit

Permalink
[PATCH] kvm: __user annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Al Viro authored and Linus Torvalds committed Feb 9, 2007
1 parent 193d073 commit 2f36698
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,7 @@ static long kvm_dev_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
struct kvm *kvm = filp->private_data;
void __user *argp = (void __user *)arg;
int r = -EINVAL;

switch (ioctl) {
Expand All @@ -1794,12 +1795,12 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_run kvm_run;

r = -EFAULT;
if (copy_from_user(&kvm_run, (void *)arg, sizeof kvm_run))
if (copy_from_user(&kvm_run, argp, sizeof kvm_run))
goto out;
r = kvm_dev_ioctl_run(kvm, &kvm_run);
if (r < 0 && r != -EINTR)
goto out;
if (copy_to_user((void *)arg, &kvm_run, sizeof kvm_run)) {
if (copy_to_user(argp, &kvm_run, sizeof kvm_run)) {
r = -EFAULT;
goto out;
}
Expand All @@ -1809,13 +1810,13 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_regs kvm_regs;

r = -EFAULT;
if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs))
if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
goto out;
r = kvm_dev_ioctl_get_regs(kvm, &kvm_regs);
if (r)
goto out;
r = -EFAULT;
if (copy_to_user((void *)arg, &kvm_regs, sizeof kvm_regs))
if (copy_to_user(argp, &kvm_regs, sizeof kvm_regs))
goto out;
r = 0;
break;
Expand All @@ -1824,7 +1825,7 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_regs kvm_regs;

r = -EFAULT;
if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs))
if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
goto out;
r = kvm_dev_ioctl_set_regs(kvm, &kvm_regs);
if (r)
Expand All @@ -1836,13 +1837,13 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_sregs kvm_sregs;

r = -EFAULT;
if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs))
if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
goto out;
r = kvm_dev_ioctl_get_sregs(kvm, &kvm_sregs);
if (r)
goto out;
r = -EFAULT;
if (copy_to_user((void *)arg, &kvm_sregs, sizeof kvm_sregs))
if (copy_to_user(argp, &kvm_sregs, sizeof kvm_sregs))
goto out;
r = 0;
break;
Expand All @@ -1851,7 +1852,7 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_sregs kvm_sregs;

r = -EFAULT;
if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs))
if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
goto out;
r = kvm_dev_ioctl_set_sregs(kvm, &kvm_sregs);
if (r)
Expand All @@ -1863,13 +1864,13 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_translation tr;

r = -EFAULT;
if (copy_from_user(&tr, (void *)arg, sizeof tr))
if (copy_from_user(&tr, argp, sizeof tr))
goto out;
r = kvm_dev_ioctl_translate(kvm, &tr);
if (r)
goto out;
r = -EFAULT;
if (copy_to_user((void *)arg, &tr, sizeof tr))
if (copy_to_user(argp, &tr, sizeof tr))
goto out;
r = 0;
break;
Expand All @@ -1878,7 +1879,7 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_interrupt irq;

r = -EFAULT;
if (copy_from_user(&irq, (void *)arg, sizeof irq))
if (copy_from_user(&irq, argp, sizeof irq))
goto out;
r = kvm_dev_ioctl_interrupt(kvm, &irq);
if (r)
Expand All @@ -1890,7 +1891,7 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_debug_guest dbg;

r = -EFAULT;
if (copy_from_user(&dbg, (void *)arg, sizeof dbg))
if (copy_from_user(&dbg, argp, sizeof dbg))
goto out;
r = kvm_dev_ioctl_debug_guest(kvm, &dbg);
if (r)
Expand All @@ -1902,7 +1903,7 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_memory_region kvm_mem;

r = -EFAULT;
if (copy_from_user(&kvm_mem, (void *)arg, sizeof kvm_mem))
if (copy_from_user(&kvm_mem, argp, sizeof kvm_mem))
goto out;
r = kvm_dev_ioctl_set_memory_region(kvm, &kvm_mem);
if (r)
Expand All @@ -1913,21 +1914,21 @@ static long kvm_dev_ioctl(struct file *filp,
struct kvm_dirty_log log;

r = -EFAULT;
if (copy_from_user(&log, (void *)arg, sizeof log))
if (copy_from_user(&log, argp, sizeof log))
goto out;
r = kvm_dev_ioctl_get_dirty_log(kvm, &log);
if (r)
goto out;
break;
}
case KVM_GET_MSRS:
r = msr_io(kvm, (void __user *)arg, get_msr, 1);
r = msr_io(kvm, argp, get_msr, 1);
break;
case KVM_SET_MSRS:
r = msr_io(kvm, (void __user *)arg, do_set_msr, 0);
r = msr_io(kvm, argp, do_set_msr, 0);
break;
case KVM_GET_MSR_INDEX_LIST: {
struct kvm_msr_list __user *user_msr_list = (void __user *)arg;
struct kvm_msr_list __user *user_msr_list = argp;
struct kvm_msr_list msr_list;
unsigned n;

Expand Down

0 comments on commit 2f36698

Please sign in to comment.