ia64/xen-unstable

changeset 8313:82e283d25f3c

In all cases in dom0_ops.c, return EFAULT if copy_user
fails.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Dec 10 15:54:27 2005 +0100 (2005-12-10)
parents 1712c7882f7e
children 167dc1fb722a
files xen/common/dom0_ops.c
line diff
     1.1 --- a/xen/common/dom0_ops.c	Sat Dec 10 00:11:33 2005 +0000
     1.2 +++ b/xen/common/dom0_ops.c	Sat Dec 10 15:54:27 2005 +0100
     1.3 @@ -216,7 +216,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     1.4          ret = 0;
     1.5  
     1.6          op->u.createdomain.domain = d->domain_id;
     1.7 -        copy_to_user(u_dom0_op, op, sizeof(*op));
     1.8 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
     1.9 +            ret = -EFAULT;
    1.10      }
    1.11      break;
    1.12  
    1.13 @@ -341,14 +342,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.14      case DOM0_SCHEDCTL:
    1.15      {
    1.16          ret = sched_ctl(&op->u.schedctl);
    1.17 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.18 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.19 +            ret = -EFAULT;
    1.20      }
    1.21      break;
    1.22  
    1.23      case DOM0_ADJUSTDOM:
    1.24      {
    1.25          ret = sched_adjdom(&op->u.adjustdom);
    1.26 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.27 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.28 +            ret = -EFAULT;
    1.29      }
    1.30      break;
    1.31  
    1.32 @@ -376,7 +379,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.33          getdomaininfo(d, &op->u.getdomaininfo);
    1.34  
    1.35          if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
    1.36 -            ret = -EINVAL;
    1.37 +            ret = -EFAULT;
    1.38  
    1.39          put_domain(d);
    1.40      }
    1.41 @@ -411,7 +414,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.42  
    1.43              if ( copy_to_user(buffer, &info, sizeof(dom0_getdomaininfo_t)) )
    1.44              {
    1.45 -                ret = -EINVAL;
    1.46 +                ret = -EFAULT;
    1.47                  break;
    1.48              }
    1.49              
    1.50 @@ -427,7 +430,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.51          op->u.getdomaininfolist.num_domains = num_domains;
    1.52  
    1.53          if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.54 -            ret = -EINVAL;
    1.55 +            ret = -EFAULT;
    1.56      }
    1.57      break;
    1.58  
    1.59 @@ -520,7 +523,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.60      case DOM0_TBUFCONTROL:
    1.61      {
    1.62          ret = tb_control(&op->u.tbufcontrol);
    1.63 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.64 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.65 +            ret = -EFAULT;
    1.66      }
    1.67      break;
    1.68      
    1.69 @@ -530,15 +534,18 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.70              &op->u.readconsole.buffer, 
    1.71              &op->u.readconsole.count,
    1.72              op->u.readconsole.clear); 
    1.73 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.74 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.75 +            ret = -EFAULT;
    1.76      }
    1.77      break;
    1.78  
    1.79      case DOM0_SCHED_ID:
    1.80      {
    1.81          op->u.sched_id.sched_id = sched_id();
    1.82 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.83 -        ret = 0;        
    1.84 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.85 +            ret = -EFAULT;
    1.86 +        else
    1.87 +            ret = 0;
    1.88      }
    1.89      break;
    1.90  
    1.91 @@ -576,7 +583,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.92      {
    1.93          extern int perfc_control(dom0_perfccontrol_t *);
    1.94          ret = perfc_control(&op->u.perfccontrol);
    1.95 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.96 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    1.97 +            ret = -EFAULT;
    1.98      }
    1.99      break;
   1.100  #endif