about summary refs log tree commit diff
path: root/frida_mode/src/seccomp/seccomp_event.c
blob: e6585f1d7e00fdfa68f85eb4814ff87ee5e93d98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#if defined(__linux__) && !defined(__ANDROID__)

  #include <stdint.h>
  #include <stdio.h>
  #include <sys/syscall.h>
  #include <unistd.h>

  #include "seccomp.h"
  #include "util.h"

int seccomp_event_create(void) {

  #ifdef SYS_eventfd
  int fd = syscall(SYS_eventfd, 0, 0);
  #else
    #ifdef SYS_eventfd2
  int fd = syscall(SYS_eventfd2, 0, 0);
    #endif
  #endif
  if (fd < 0) { FFATAL("seccomp_event_create"); }
  return fd;

}

void seccomp_event_signal(int fd) {

  uint64_t val = 1;
  if (write(fd, &val, sizeof(uint64_t)) != sizeof(uint64_t)) {

    FFATAL("seccomp_event_signal");

  }

}

void seccomp_event_wait(int fd) {

  uint64_t val = 1;
  if (read(fd, &val, sizeof(uint64_t)) != sizeof(uint64_t)) {

    FFATAL("seccomp_event_wait");

  }

}

void seccomp_event_destroy(int fd) {

  if (close(fd) < 0) { FFATAL("seccomp_event_destroy"); }

}

#endif