link: don't allow superuser to link to directories
authorAlan Cox <alan@linux.intel.com>
Wed, 21 Feb 2018 20:40:49 +0000 (20:40 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 21 Feb 2018 20:40:49 +0000 (20:40 +0000)
Kernel/syscall_fs3.c

index c7c8141..b840496 100644 (file)
@@ -178,8 +178,10 @@ arg_t _link(void)
        if (!(ino = n_open(name1, NULLINOPTR)))
                return (-1);
 
-       if (getmode(ino) == MODE_R(F_DIR))
+       if (getmode(ino) == MODE_R(F_DIR)) {
+               udata.u_error = EISDIR;
                goto nogood;
+       }
 
        if (ino->c_node.i_nlink == 0xFFFF) {
                udata.u_error = EMLINK;