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.
This commit is contained in:
Andreas Kling 2020-01-15 21:19:26 +01:00
commit d79de38bd2
Notes: sideshowbarker 2024-07-19 10:02:52 +09:00

View file

@ -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