Skip to content

Commit

Permalink
chore(driver): adopt consistent approach in fd casting for dup syscalls
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Mar 22, 2024
1 parent 459b65c commit 18d0627
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions driver/ppm_fillers.c
Original file line number Diff line number Diff line change
Expand Up @@ -5710,13 +5710,12 @@ int f_sys_dup_e(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;

/*
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int32_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

Expand All @@ -5727,8 +5726,6 @@ int f_sys_dup_x(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;


int64_t retval = (int64_t)syscall_get_return_value(current, args->regs);
res = val_to_ring(args, retval, 0, false, 0);
Expand All @@ -5738,7 +5735,7 @@ int f_sys_dup_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int64_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

Expand All @@ -5749,13 +5746,12 @@ int f_sys_dup2_e(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;

/*
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int32_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

Expand All @@ -5766,8 +5762,6 @@ int f_sys_dup2_x(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;


int64_t retval = (int64_t)syscall_get_return_value(current, args->regs);
res = val_to_ring(args, retval, 0, false, 0);
Expand All @@ -5777,18 +5771,17 @@ int f_sys_dup2_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int64_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

/*
* newfd
*/
syscall_get_arguments_deprecated(args, 1, 1, &val);
fd = (int64_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res)
;
fd = (int32_t) val;
res = val_to_ring(args, (int32_t)fd, 0, false, 0);
CHECK_RES(res);

return add_sentinel(args);
}
Expand All @@ -5797,13 +5790,12 @@ int f_sys_dup3_e(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;

/*
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int64_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

Expand All @@ -5814,7 +5806,6 @@ int f_sys_dup3_x(struct event_filler_arguments *args)
{
int res;
unsigned long val;
int64_t fd = 0;

int64_t retval = (int64_t)syscall_get_return_value(current, args->regs);
res = val_to_ring(args, retval, 0, false, 0);
Expand All @@ -5824,15 +5815,15 @@ int f_sys_dup3_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
fd = (int64_t) val;
int32_t fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

/*
* newfd
*/
syscall_get_arguments_deprecated(args, 1, 1, &val);
fd = (int64_t) val;
fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

Expand Down

0 comments on commit 18d0627

Please sign in to comment.