2 * Functions for handling the system call tables.
3 * These functions are only used by architectures that have either 32 or 64 bit syscalls, but not both.
11 #include "trinity.h" // ARRAY_SIZE, alloc_shared
19 const struct syscalltable
*syscalls
;
21 unsigned int max_nr_syscalls
;
23 void activate_syscall(unsigned int calln
)
25 activate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
28 void deactivate_syscall(unsigned int calln
)
30 deactivate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
33 void toggle_syscall_n(int calln
, bool state
, const char *arg
, const char *arg_name
)
36 outputerr("No idea what syscall (%s) is.\n", arg
);
40 validate_specific_syscall(syscalls
, calln
);
43 syscalls
[calln
].entry
->flags
|= ACTIVE
;
44 activate_syscall(calln
);
46 syscalls
[calln
].entry
->flags
|= TO_BE_DEACTIVATED
;
49 output(0, "Marking syscall %s (%d) as to be %sabled.\n",
51 state
? "en" : "dis");
55 void enable_random_syscalls_uniarch(void)
60 call
= rand() % max_nr_syscalls
;
62 if (validate_specific_syscall_silent(syscalls
, call
) == FALSE
)
66 if (is_syscall_net_related(syscalls
, call
) == FALSE
)
69 /* if we've set this to be disabled, don't enable it! */
70 if (syscalls
[call
].entry
->flags
& TO_BE_DEACTIVATED
)
73 toggle_syscall_n(call
, TRUE
, syscalls
[call
].entry
->name
, syscalls
[call
].entry
->name
);
76 void disable_non_net_syscalls_uniarch(void)
81 if (validate_specific_syscall_silent(syscalls
, i
) == FALSE
)
84 if (syscalls
[i
].entry
->flags
& ACTIVE
) {
85 if (is_syscall_net_related(syscalls
, i
) == FALSE
) {
86 toggle_syscall_n(i
, FALSE
, syscalls
[i
].entry
->name
, syscalls
[i
].entry
->name
);
92 int setup_syscall_group_uniarch(unsigned int group
)
97 if (syscalls
[i
].entry
->group
== group
)
101 if (shm
->nr_active_syscalls
== 0) {
102 outputstd("No syscalls found in group\n");
105 outputstd("Found %d syscalls in group\n", shm
->nr_active_syscalls
);
111 void mark_all_syscalls_active_uniarch(void)
115 for_each_syscall(i
) {
116 syscalls
[i
].entry
->flags
|= ACTIVE
;
121 void init_syscalls_uniarch(void)
125 for_each_syscall(i
) {
126 if (syscalls
[i
].entry
->flags
& ACTIVE
)
127 if (syscalls
[i
].entry
->init
)
128 syscalls
[i
].entry
->init();
132 void deactivate_disabled_syscalls_uniarch(void)
136 for_each_syscall(i
) {
137 if (syscalls
[i
].entry
->flags
& TO_BE_DEACTIVATED
) {
138 syscalls
[i
].entry
->flags
&= ~(ACTIVE
|TO_BE_DEACTIVATED
);
139 deactivate_syscall(i
);
140 output(0, "Marked syscall %s (%d) as deactivated.\n",
141 syscalls
[i
].entry
->name
, syscalls
[i
].entry
->number
);
146 void dump_syscall_tables_uniarch(void)
150 outputstd("syscalls: %d\n", max_nr_syscalls
);
152 for_each_syscall(i
) {
153 outputstd("entrypoint %d %s : ",
154 syscalls
[i
].entry
->number
,
155 syscalls
[i
].entry
->name
);
156 show_state(syscalls
[i
].entry
->flags
& ACTIVE
);
157 if (syscalls
[i
].entry
->flags
& AVOID_SYSCALL
)
163 void display_enabled_syscalls_uniarch(void)
167 for_each_syscall(i
) {
168 if (syscalls
[i
].entry
->flags
& ACTIVE
)
169 output(0, "syscall %d:%s enabled.\n", i
, syscalls
[i
].entry
->name
);