1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:28:11 +00:00

Kernel: open() and openat() should ignore non-permission bits in mode

This commit is contained in:
Andreas Kling 2020-01-08 13:59:22 +01:00
parent d310cf3b49
commit e1d4b19461
2 changed files with 25 additions and 0 deletions

View file

@ -1652,6 +1652,9 @@ int Process::sys$open(const Syscall::SC_open_params* user_params)
if (!validate_read(params.path, params.path_length))
return -EFAULT;
// Ignore everything except permission bits.
mode &= 04777;
String path = copy_string_from_user(params.path, params.path_length);
int fd = alloc_fd();
#ifdef DEBUG_IO
@ -1681,6 +1684,9 @@ int Process::sys$openat(const Syscall::SC_openat_params* user_params)
int options = params.options;
u16 mode = params.mode;
// Ignore everything except permission bits.
mode &= 04777;
if (params.path_length <= 0)
return -EINVAL;
if (!validate_read(params.path, params.path_length))