From: Alan Cox Date: Mon, 12 Jan 2015 11:05:53 +0000 (+0000) Subject: ioctl: implement the superuser bit X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f87907537f9caed21520ff95971739e853861cda;p=FUZIX.git ioctl: implement the superuser bit We need to check this at the syscall level so we can allow it to be invoked internally without security restrictions but directly with --- diff --git a/Kernel/syscall_fs.c b/Kernel/syscall_fs.c index 6ce0d2e2..3a175cae 100644 --- a/Kernel/syscall_fs.c +++ b/Kernel/syscall_fs.c @@ -257,23 +257,26 @@ int16_t _ioctl(void) uint16_t dev; if ((ino = getinode(fd)) == NULLINODE) - return (-1); + return -1; if (!(isdevice(ino))) { udata.u_error = ENOTTY; - return (-1); + return -1; } + if ((request & IOCTL_SUPER) && esuper()) + return -1; + if (!(getperm(ino) & OTH_WR)) { udata.u_error = EPERM; - return (-1); + return -1; } dev = ino->c_node.i_addr[0]; /* top bit of request is reserved for kernel originated magic */ if (d_ioctl(dev, request & 0x7FFF, data)) - return (-1); + return -1; return (0); }