Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(driver): create consistencies (syscall_arg_t) #1435

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions driver/ppm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ struct ppm_ring_buffer_context {

#define STR_STORAGE_SIZE PAGE_SIZE

typedef unsigned long syscall_arg_t;

/*
* Global functions
*
Expand Down
20 changes: 10 additions & 10 deletions driver/ppm_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
if(fromuser)
{
len = ppm_strncpy_from_user(args->buffer + args->arg_data_offset,
(const char __user *)(syscall_arg_t)val, max_arg_size);
(const char __user *)(unsigned long)val, max_arg_size);

if(unlikely(len < 0))
{
Expand All @@ -747,7 +747,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
else
{
len = (int)strlcpy(args->buffer + args->arg_data_offset,
(const char *)(syscall_arg_t)val,
(const char *)(unsigned long)val,
max_arg_size);
/* WARNING: `strlcpy` returns the length of the string it tries to create
* so `len` could also be greater than `max_arg_size`, but please note that the copied
Expand Down Expand Up @@ -790,7 +790,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,

/* Returns the number of bytes NOT read. */
len = (int)ppm_copy_from_user(args->buffer + args->arg_data_offset,
(const void __user *)(syscall_arg_t)val,
(const void __user *)(unsigned long)val,
dpi_lookahead_size);

if(unlikely(len != 0))
Expand Down Expand Up @@ -820,7 +820,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,

if (val_len > dpi_lookahead_size) {
len = (int)ppm_copy_from_user(args->buffer + args->arg_data_offset + dpi_lookahead_size,
(const uint8_t __user *)(syscall_arg_t)val + dpi_lookahead_size,
(const uint8_t __user *)(unsigned long)val + dpi_lookahead_size,
val_len - dpi_lookahead_size);

if (unlikely(len != 0))
Expand All @@ -838,7 +838,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
#ifdef UDIG
u32 sl = args->consumer->snaplen;
#else
u32 sl = compute_snaplen(args, (char *)(syscall_arg_t)val, val_len);
u32 sl = compute_snaplen(args, (char *)(unsigned long)val, val_len);
#endif
if (val_len > sl)
val_len = sl;
Expand All @@ -848,7 +848,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
return PPM_FAILURE_BUFFER_FULL;

memcpy(args->buffer + args->arg_data_offset,
(void *)(syscall_arg_t)val, val_len);
(void *)(unsigned long)val, val_len);

len = val_len;
}
Expand All @@ -875,7 +875,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
if(fromuser)
{
len = (int)ppm_copy_from_user(args->buffer + args->arg_data_offset,
(const void __user *)(syscall_arg_t)val,
(const void __user *)(unsigned long)val,
val_len);

if(unlikely(len != 0))
Expand All @@ -888,7 +888,7 @@ int val_to_ring(struct event_filler_arguments *args, uint64_t val, u32 val_len,
else
{
memcpy(args->buffer + args->arg_data_offset,
(void *)(syscall_arg_t)val, val_len);
(void *)(unsigned long)val, val_len);

len = val_len;
}
Expand Down Expand Up @@ -1740,7 +1740,7 @@ int32_t compat_parse_readv_writev_bufs(struct event_filler_arguments *args, cons
int f_sys_autofill(struct event_filler_arguments *args)
{
int res;
syscall_arg_t val;
unsigned long val;
u32 j;
int64_t retval;

Expand All @@ -1751,7 +1751,7 @@ int f_sys_autofill(struct event_filler_arguments *args)
if (evinfo->autofill_args[j].id >= 0) {
#ifdef UDIG
{
syscall_arg_t syscall_args[6] = {0};
unsigned long syscall_args[6] = {0};
ppm_syscall_get_arguments(current, args->regs, syscall_args);
val = syscall_args[evinfo->autofill_args[j].id];
}
Expand Down
42 changes: 21 additions & 21 deletions driver/ppm_fillers.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int f_sys_empty(struct event_filler_arguments *args)
int f_sys_single(struct event_filler_arguments *args)
{
int res;
syscall_arg_t val;
unsigned long val;

syscall_get_arguments_deprecated(args, 0, 1, &val);
res = val_to_ring(args, val, 0, true, 0);
Expand Down Expand Up @@ -337,9 +337,9 @@ static inline void get_fd_fmode_created(int64_t fd, unsigned long* flags)

int f_sys_open_e(struct event_filler_arguments *args)
{
syscall_arg_t val;
syscall_arg_t flags;
syscall_arg_t modes;
unsigned long val;
unsigned long flags;
unsigned long modes;
char *name = NULL;
int res;

Expand Down Expand Up @@ -375,10 +375,10 @@ int f_sys_open_e(struct event_filler_arguments *args)

int f_sys_open_x(struct event_filler_arguments *args)
{
syscall_arg_t val;
syscall_arg_t flags;
syscall_arg_t scap_flags;
syscall_arg_t modes;
unsigned long val;
unsigned long flags;
unsigned long scap_flags;
unsigned long modes;
uint32_t dev = 0;
uint64_t ino = 0;
int res;
Expand Down Expand Up @@ -1586,7 +1586,7 @@ int f_proc_startupdate(struct event_filler_arguments *args)
int f_sys_execve_e(struct event_filler_arguments *args)
{
int res;
syscall_arg_t val;
unsigned long val;

/*
* filename
Expand All @@ -1601,7 +1601,7 @@ int f_sys_execve_e(struct event_filler_arguments *args)
int f_sys_execveat_e(struct event_filler_arguments *args)
{
int res;
syscall_arg_t val;
unsigned long val;
unsigned long flags;
s32 fd;

Expand Down Expand Up @@ -1660,7 +1660,7 @@ int f_sys_socket_bind_x(struct event_filler_arguments *args)
int err = 0;
u16 size = 0;
struct sockaddr __user *usrsockaddr;
syscall_arg_t val;
unsigned long val;
struct sockaddr_storage address;
char *targetbuf = args->str_storage;

Expand Down Expand Up @@ -1720,7 +1720,7 @@ int f_sys_connect_e(struct event_filler_arguments *args)
u16 size = 0;
char *targetbuf = args->str_storage;
struct sockaddr_storage address;
syscall_arg_t val;
unsigned long val;

syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int)val;
Expand Down Expand Up @@ -1781,7 +1781,7 @@ int f_sys_connect_x(struct event_filler_arguments *args)
u16 size = 0;
char *targetbuf = args->str_storage;
struct sockaddr_storage address;
syscall_arg_t val;
unsigned long val;

/*
* Push the result
Expand Down Expand Up @@ -2130,7 +2130,7 @@ int f_sys_setsockopt_x(struct event_filler_arguments *args)
{
int res = 0;
long retval = 0;
syscall_arg_t val[5] = {0};
unsigned long val[5] = {0};
s32 fd = 0;

/* Parameter 1: res (type: PT_ERRNO) */
Expand Down Expand Up @@ -2171,7 +2171,7 @@ int f_sys_getsockopt_x(struct event_filler_arguments *args)
int64_t retval = 0;
uint32_t optlen = 0;
s32 fd = 0;
syscall_arg_t val[5] = {0};
unsigned long val[5] = {0};

/* Get all the five arguments */
syscall_get_arguments_deprecated(args, 0, 5, val);
Expand Down Expand Up @@ -2236,10 +2236,10 @@ int f_sys_accept_x(struct event_filler_arguments *args)
int fd;
char *targetbuf = args->str_storage;
u16 size = 0;
syscall_arg_t queuepct = 0;
syscall_arg_t ack_backlog = 0;
syscall_arg_t max_ack_backlog = 0;
syscall_arg_t srvskfd;
unsigned long queuepct = 0;
unsigned long ack_backlog = 0;
unsigned long max_ack_backlog = 0;
unsigned long srvskfd;
int err = 0;
struct socket *sock;

Expand Down Expand Up @@ -7808,8 +7808,8 @@ int f_sys_prctl_x(struct event_filler_arguments *args)
{
int res;
int retval;
syscall_arg_t option;
syscall_arg_t arg2;
unsigned long option;
unsigned long arg2;

/* Parameter 1: res (type: PT_ERRNO) */
retval = (int64_t)syscall_get_return_value(current, args->regs);
Expand Down