ioctl: move the write check into the drivers
authorAlan Cox <alan@linux.intel.com>
Sat, 23 Jul 2016 21:24:21 +0000 (22:24 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 23 Jul 2016 21:24:21 +0000 (22:24 +0100)
Kernel/dev/blkdev.c
Kernel/syscall_fs.c

index 8791ecf..c50fb73 100644 (file)
@@ -157,6 +157,11 @@ int blkdev_ioctl(uint8_t minor, uint16_t request, char *data)
     if (request != BLKFLSBUF)
        return -1;
 
+    if (!(getperm(ino) & OTH_WR)) {
+       udata.u_error = EPERM;
+       return -1;
+    }
+
     /* we trust that blkdev_open() has already verified that this minor number is valid */
     blk_op.blkdev = &blkdev_table[minor >> 4];
 
index 43d1334..1b29c08 100644 (file)
@@ -263,10 +263,6 @@ arg_t _ioctl(void)
        if ((request & IOCTL_SUPER) && esuper())
                return -1;
 
-       if (!(getperm(ino) & OTH_WR)) {
-               udata.u_error = EPERM;
-               return -1;
-       }
 
        dev = ino->c_node.i_addr[0];