Fixed some ioctl() permissions. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Thu, 06 Dec 2012 11:24:04 +0100
branchstable-1.5
changeset 2477 1d5ebfb7fec1
parent 2476 9a0d30056e70
child 2478 9640948881fd
Fixed some ioctl() permissions.
master/ioctl.c
--- a/master/ioctl.c	Wed Dec 05 15:54:49 2012 +0100
+++ b/master/ioctl.c	Thu Dec 06 11:24:04 2012 +0100
@@ -1718,6 +1718,10 @@
 {
     size_t send_interval;
 
+    if (unlikely(!ctx->requested)) {
+        return -EPERM;
+    }
+
     if (copy_from_user(&send_interval, (void __user *) arg,
                 sizeof(send_interval))) {
         return -EFAULT;
@@ -1782,9 +1786,6 @@
 {
     ec_master_state_t data;
 
-    if (unlikely(!ctx->requested))
-        return -EPERM;
-
     ecrt_master_state(master, &data);
 
     if (copy_to_user((void __user *) arg, &data, sizeof(data)))
@@ -1807,10 +1808,6 @@
     ec_master_link_state_t state;
     int ret;
 
-    if (unlikely(!ctx->requested)) {
-        return -EPERM;
-    }
-
     if (copy_from_user(&ioctl, (void __user *) arg, sizeof(ioctl))) {
         return -EFAULT;
     }
@@ -1971,9 +1968,6 @@
         ec_ioctl_context_t *ctx /**< Private data structure of file handle. */
         )
 {
-    if (unlikely(!ctx->requested))
-        return -EPERM;
-
     down(&master->master_sem);
     ecrt_master_reset(master);
     up(&master->master_sem);
@@ -4170,10 +4164,6 @@
             ret = ec_ioctl_sc_emerg_clear(master, arg, ctx);
             break;
         case EC_IOCTL_SC_EMERG_OVERRUNS:
-            if (!ctx->writable) {
-                ret = -EPERM;
-                break;
-            }
             ret = ec_ioctl_sc_emerg_overruns(master, arg, ctx);
             break;
         case EC_IOCTL_SC_SDO_REQUEST: