mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
raw sockets: make creating them a privileged operation
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
|
||||
#define AUTH_ACTIONS_NETWORK_CONFIGURE 1
|
||||
#define AUTH_ACTIONS_NETWORK_BINDRESERVED 2
|
||||
#define AUTH_ACTIONS_NETWORK_CREATERAW 4
|
||||
|
||||
typedef int (*authlistener_t)(cred_t *cred, int actions, void *arg0, void *arg1, void *arg2);
|
||||
|
||||
|
||||
@@ -6,13 +6,10 @@
|
||||
#include <spinlock.h>
|
||||
#include <kernel/interrupt.h>
|
||||
#include <ringbuffer.h>
|
||||
#include <kernel/auth.h>
|
||||
#include <list.h>
|
||||
|
||||
#define SOCKET_BUFFER (16 * 1024)
|
||||
|
||||
// TODO: check user creating socket is root
|
||||
|
||||
SPINLOCK_DEFINE(list_lock);
|
||||
static list_t socket_list;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <kernel/abi.h>
|
||||
#include <kernel/auth.h>
|
||||
#include <kernel/sock.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -48,6 +49,12 @@ syscallret_t syscall_socket(context_t *, int domain, int type, int protocol) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (socktype == SOCKET_TYPE_RAW_STRIPPED) {
|
||||
ret.errno = auth_network_check(¤t_thread()->proc->cred, AUTH_ACTIONS_NETWORK_CREATERAW, NULL, NULL);
|
||||
if (ret.errno)
|
||||
return ret;
|
||||
}
|
||||
|
||||
socket_t *socket = socket_create(socktype, protocol);
|
||||
if (socket == NULL) {
|
||||
ret.errno = ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user