Revert "ioctl: move the write check into the drivers"
authorAlan Cox <alan@linux.intel.com>
Sun, 24 Jul 2016 10:50:08 +0000 (11:50 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 24 Jul 2016 10:50:08 +0000 (11:50 +0100)
This reverts commit c2c9fa5c6bb4ae5a7cbb5fb51b42ca5ce4d4d832.

Can't do it this way because we need to care about file handle permissions
at driver level and we deliberately don't pass all the handles down

Kernel/dev/blkdev.c
Kernel/syscall_fs.c

index c50fb73..8791ecf 100644 (file)
@@ -157,11 +157,6 @@ 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 1b29c08..43d1334 100644 (file)
@@ -263,6 +263,10 @@ 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];