mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
Kernel: Return EINVAL when specifying -1 for setuid and similar syscalls
For setreuid and setresuid syscalls, -1 means to set the current uid/euid/gid/egid value, to be more convenient for programming. However, for other syscalls where we pass only one argument, there's no justification to specify -1. This behavior is identical to how Linux handles the value -1, and is influenced by the fact that the manual pages for the group of one argument syscalls that handle ID operations is ambiguous about this topic.
This commit is contained in:
parent
a3c732b8ae
commit
5a649d0fd5
5 changed files with 43 additions and 0 deletions
28
Tests/Kernel/TestInvalidUIDSet.cpp
Normal file
28
Tests/Kernel/TestInvalidUIDSet.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
TEST_CASE(test_invalid_set_uid_parameters)
|
||||
{
|
||||
auto res = setuid(-1);
|
||||
EXPECT_EQ(res, -1);
|
||||
EXPECT_EQ(errno, EINVAL);
|
||||
|
||||
res = seteuid(-1);
|
||||
EXPECT_EQ(res, -1);
|
||||
EXPECT_EQ(errno, EINVAL);
|
||||
|
||||
res = setgid(-1);
|
||||
EXPECT_EQ(res, -1);
|
||||
EXPECT_EQ(errno, EINVAL);
|
||||
|
||||
res = setegid(-1);
|
||||
EXPECT_EQ(res, -1);
|
||||
EXPECT_EQ(errno, EINVAL);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue