Skip to content

Commit

Permalink
fixup! [LibOS] Add sys.disallowed_syscalls = [ ... ] manifest option
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
  • Loading branch information
dimakuv committed May 7, 2024
1 parent 20a1004 commit f469e2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libos/include/libos_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int init_eventfd_mode(void);
void warn_unsupported_syscall(unsigned long sysno);
void debug_print_syscall_before(unsigned long sysno, ...);
void debug_print_syscall_after(unsigned long sysno, ...);
unsigned long get_syscall_number(const char* name);
int get_syscall_number(const char* name, unsigned long* out_sysno);
int init_syscalls(void);

#ifndef __alloca
Expand Down
11 changes: 7 additions & 4 deletions libos/src/libos_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,16 +1649,19 @@ void warn_unsupported_syscall(unsigned long sysno) {
log_warning("Unsupported system call %lu", sysno);
}

unsigned long get_syscall_number(const char* name) {
int get_syscall_number(const char* name, unsigned long* out_sysno) {
static_assert(LIBOS_SYSCALL_BOUND == ARRAY_SIZE(syscall_parser_table), "oops");
assert(out_sysno);

for (size_t i = 0; i < LIBOS_SYSCALL_BOUND; i++) {
if (!syscall_parser_table[i].name)
continue;
if (strcmp(name, syscall_parser_table[i].name) == 0)
return i;
if (strcmp(name, syscall_parser_table[i].name) == 0) {
*out_sysno = i;
return 0;
}
}
return LIBOS_SYSCALL_BOUND;
return -ENOSYS;
}

static int buf_write_all(const char* str, size_t size, void* arg) {
Expand Down
6 changes: 3 additions & 3 deletions libos/src/libos_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ int init_syscalls(void) {
goto out;
}

uint64_t sysno = get_syscall_number(toml_disallowed_syscall_str);
if (sysno >= LIBOS_SYSCALL_BOUND) {
uint64_t sysno;
ret = get_syscall_number(toml_disallowed_syscall_str, &sysno);
if (ret < 0) {
log_error("Unrecognized disallowed syscall `%s` in manifest at index %ld",
toml_disallowed_syscall_str, i);
ret = -EINVAL;
goto out;
}

Expand Down

0 comments on commit f469e2e

Please sign in to comment.