Skip to content

Commit

Permalink
✨ better logging of prlimit64
Browse files Browse the repository at this point in the history
  • Loading branch information
froz42 committed Nov 2, 2023
1 parent 749fd70 commit 096dea2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ SRCS += syscall/syscall_get_description.c \
syscall/param_log/log_openat_dirfd.c \
syscall/param_log/log_rlimit64_struct.c \
syscall/param_log/log_newfstatat_flags.c \
syscall/param_log/log_prlimit_resource.c \
syscall/syscall_handle.c \

# registers srcs
Expand Down
1 change: 1 addition & 0 deletions includes/syscall_strace.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
#define OPENAT_DIRFD 94
#define RLIMIT64_STRUCT 95
#define NEWFSTATAT_FLAGS 96
#define PRLIMIT_RESOURCE 97

/**
* @brief Negative if printed before the syscall, positive if printed after the
Expand Down
27 changes: 27 additions & 0 deletions srcs/syscall/param_log/log_prlimit_resource.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "param_log.h"
#include <macros.h>
#include <sys/resource.h>

static const flag_str_t resources[] = {
FLAG_STR(RLIMIT_AS),
FLAG_STR(RLIMIT_CORE),
FLAG_STR(RLIMIT_CPU),
FLAG_STR(RLIMIT_DATA),
FLAG_STR(RLIMIT_FSIZE),
FLAG_STR(RLIMIT_LOCKS),
FLAG_STR(RLIMIT_MEMLOCK),
FLAG_STR(RLIMIT_MSGQUEUE),
FLAG_STR(RLIMIT_NICE),
FLAG_STR(RLIMIT_NOFILE),
FLAG_STR(RLIMIT_NPROC),
FLAG_STR(RLIMIT_RSS),
FLAG_STR(RLIMIT_RTPRIO),
FLAG_STR(RLIMIT_RTTIME),
FLAG_STR(RLIMIT_SIGPENDING),
FLAG_STR(RLIMIT_STACK),
};

int log_PRLIMIT_RESOURCE(uint64_t value)
{
return option_log(value, resources, ELEM_COUNT(resources), "RLIMIT_???");
}
3 changes: 2 additions & 1 deletion srcs/syscall/param_log/param_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,5 @@ int log_KEYCTL_CMD(uint64_t value);
int log_IOPRIO_WHICH(uint64_t value);
int log_OPENAT_DIRFD(int value);
int log_RLIMIT64_STRUCT(uint64_t value, syscall_log_param_t *context);
int log_NEWFSTATAT_FLAGS(uint64_t value);
int log_NEWFSTATAT_FLAGS(uint64_t value);
int log_PRLIMIT_RESOURCE(uint64_t value);
2 changes: 1 addition & 1 deletion srcs/syscall/syscall_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static const syscall_description_t x86_64_syscalls[] = {
[299] = {"recvmmsg", INT, {-INT, -PTR, -INT, -HEX, KERNEL_TIMESPEC_STRUCT, NONE}},
[300] = {"fanotify_init", INT, {-INT, -INT, NONE}},
[301] = {"fanotify_mark", INT, {-INT, -INT, -HEX, -INT, -STRING, NONE}},
[302] = {"prlimit64", INT, {-INT, -INT, -RLIMIT64_STRUCT, RLIMIT64_STRUCT, NONE}},
[302] = {"prlimit64", INT, {-INT, -PRLIMIT_RESOURCE, -RLIMIT64_STRUCT, RLIMIT64_STRUCT, NONE}},
[303] = {"name_to_handle_at", INT, {-OPENAT_DIRFD, -STRING, -PTR, INT_PTR, INT}},
[304] = {"open_by_handle_at", INT, {-INT, -PTR, INT, NONE}},
[305] = {"clock_adjtime", INT, {-CLOCKID_T, -KERNEL_TIMEX_STRUCT, NONE}},
Expand Down
1 change: 1 addition & 0 deletions srcs/syscall/syscall_log_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static const log_function_t log_functions[] = {
ADD_LOGGER(OPENAT_DIRFD),
ADD_LOGGER(RLIMIT64_STRUCT),
ADD_LOGGER(NEWFSTATAT_FLAGS),
ADD_LOGGER(PRLIMIT_RESOURCE),
};

typedef int (*log_function_with_param_t)(uint64_t value, syscall_log_param_t *context);
Expand Down

0 comments on commit 096dea2

Please sign in to comment.