mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
Kernel+ping: Only allow superuser to create SOCK_RAW sockets
/bin/ping is now setuid-root, and will drop privileges immediately after opening a raw socket.
This commit is contained in:
parent
5c918d0e71
commit
3f254bfbc8
Notes:
sideshowbarker
2024-07-19 10:31:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3f254bfbc8e
@ -2609,6 +2609,8 @@ size_t Process::amount_purgeable_nonvolatile() const
|
||||
|
||||
int Process::sys$socket(int domain, int type, int protocol)
|
||||
{
|
||||
if ((type & SOCK_TYPE_MASK) == SOCK_RAW && !is_superuser())
|
||||
return -EACCES;
|
||||
int fd = alloc_fd();
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
@ -82,6 +82,7 @@ else
|
||||
find ../Userland/ -type f -perm +111 -exec cp {} mnt/bin/ \;
|
||||
fi
|
||||
chmod 4755 mnt/bin/su
|
||||
chmod 4755 mnt/bin/ping
|
||||
echo "done"
|
||||
|
||||
printf "installing applications... "
|
||||
|
@ -37,6 +37,11 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (setgid(getgid()) || setuid(getuid())) {
|
||||
fprintf(stderr, "Failed to drop privileges.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct timeval timeout {
|
||||
1, 0
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user