Jelajahi Sumber

Kernel: Don't allow userspace to sys$open() literal symlinks

The O_NOFOLLOW_NOERROR is an internal kernel mechanism used for the
implementation of sys$readlink() and sys$lstat().

There is no reason to allow userspace to open symlinks directly.
Andreas Kling 5 tahun lalu
induk
melakukan
d79de38bd2
1 mengubah file dengan 6 tambahan dan 0 penghapusan
  1. 6 0
      Kernel/Process.cpp

+ 6 - 0
Kernel/Process.cpp

@@ -1863,6 +1863,9 @@ int Process::sys$open(const Syscall::SC_open_params* user_params)
     auto options = params.options;
     auto mode = params.mode;
 
+    if (options & O_NOFOLLOW_NOERROR)
+        return -EINVAL;
+
     if ((options & O_RDWR) || (options & O_WRONLY))
         REQUIRE_PROMISE(wpath);
     else
@@ -1905,6 +1908,9 @@ int Process::sys$openat(const Syscall::SC_openat_params* user_params)
     int options = params.options;
     u16 mode = params.mode;
 
+    if (options & O_NOFOLLOW_NOERROR)
+        return -EINVAL;
+
     if ((options & O_RDWR) || (options & O_WRONLY))
         REQUIRE_PROMISE(wpath);
     else