sys: specify context for syscall filter
Specify a context to enable different processes using different (more restrictive) syscall filters.
This commit is contained in:
parent
3e537416a9
commit
e6848b1e3f
5 changed files with 12 additions and 6 deletions
2
main.c
2
main.c
|
@ -596,7 +596,7 @@ int main
|
|||
CAM_OpenUnixSocket();
|
||||
|
||||
if (scfilter_level)
|
||||
SYS_EnableSystemCallFilter(scfilter_level);
|
||||
SYS_EnableSystemCallFilter(scfilter_level, SYS_MAIN_PROCESS);
|
||||
|
||||
if (ref_mode == REF_ModeNormal && CNF_GetInitSources() > 0) {
|
||||
ref_mode = REF_ModeInitStepSlew;
|
||||
|
|
4
sys.c
4
sys.c
|
@ -114,10 +114,10 @@ void SYS_DropRoot(uid_t uid, gid_t gid)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void SYS_EnableSystemCallFilter(int level)
|
||||
void SYS_EnableSystemCallFilter(int level, SYS_SystemCallContext context)
|
||||
{
|
||||
#if defined(LINUX) && defined(FEAT_SCFILTER)
|
||||
SYS_Linux_EnableSystemCallFilter(level);
|
||||
SYS_Linux_EnableSystemCallFilter(level, context);
|
||||
#else
|
||||
LOG_FATAL("system call filter not supported");
|
||||
#endif
|
||||
|
|
6
sys.h
6
sys.h
|
@ -38,9 +38,13 @@ extern void SYS_Finalise(void);
|
|||
/* Drop root privileges to the specified user and group */
|
||||
extern void SYS_DropRoot(uid_t uid, gid_t gid);
|
||||
|
||||
typedef enum {
|
||||
SYS_MAIN_PROCESS,
|
||||
} SYS_SystemCallContext;
|
||||
|
||||
/* Enable a system call filter to allow only system calls
|
||||
which chronyd normally needs after initialization */
|
||||
extern void SYS_EnableSystemCallFilter(int level);
|
||||
extern void SYS_EnableSystemCallFilter(int level, SYS_SystemCallContext context);
|
||||
|
||||
extern void SYS_SetScheduler(int SchedPriority);
|
||||
extern void SYS_LockMemory(void);
|
||||
|
|
|
@ -474,7 +474,7 @@ void check_seccomp_applicability(void)
|
|||
/* ================================================== */
|
||||
|
||||
void
|
||||
SYS_Linux_EnableSystemCallFilter(int level)
|
||||
SYS_Linux_EnableSystemCallFilter(int level, SYS_SystemCallContext context)
|
||||
{
|
||||
const int syscalls[] = {
|
||||
/* Clock */
|
||||
|
|
|
@ -27,13 +27,15 @@
|
|||
#ifndef GOT_SYS_LINUX_H
|
||||
#define GOT_SYS_LINUX_H
|
||||
|
||||
#include "sys.h"
|
||||
|
||||
extern void SYS_Linux_Initialise(void);
|
||||
|
||||
extern void SYS_Linux_Finalise(void);
|
||||
|
||||
extern void SYS_Linux_DropRoot(uid_t uid, gid_t gid, int clock_control);
|
||||
|
||||
extern void SYS_Linux_EnableSystemCallFilter(int level);
|
||||
extern void SYS_Linux_EnableSystemCallFilter(int level, SYS_SystemCallContext context);
|
||||
|
||||
extern int SYS_Linux_CheckKernelVersion(int req_major, int req_minor);
|
||||
|
||||
|
|
Loading…
Reference in a new issue