Skip to content

Commit

Permalink
fix(kmod): fix signedness on fd of 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 413b7a6 commit 459b65c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion driver/SCHEMA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.19.0
2.19.1
33 changes: 24 additions & 9 deletions driver/ppm_fillers.c
Original file line number Diff line number Diff line change
Expand Up @@ -5710,12 +5710,14 @@ 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);
res = val_to_ring(args, val, 0, false, 0);
fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

return add_sentinel(args);
Expand All @@ -5725,6 +5727,7 @@ 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);
Expand All @@ -5735,7 +5738,8 @@ int f_sys_dup_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
res = val_to_ring(args, val, 0, false, 0);
fd = (int64_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

return add_sentinel(args);
Expand All @@ -5745,12 +5749,14 @@ 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);
res = val_to_ring(args, val, 0, false, 0);
fd = (int32_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

return add_sentinel(args);
Expand All @@ -5760,6 +5766,7 @@ 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);
Expand All @@ -5770,15 +5777,18 @@ int f_sys_dup2_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
res = val_to_ring(args, val, 0, false, 0);
fd = (int64_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);
res = val_to_ring(args, val, 0, false, 0);
CHECK_RES(res);
fd = (int64_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res)
;

return add_sentinel(args);
}
Expand All @@ -5787,12 +5797,14 @@ 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);
res = val_to_ring(args, val, 0, false, 0);
fd = (int64_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

return add_sentinel(args);
Expand All @@ -5802,6 +5814,7 @@ 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 @@ -5811,14 +5824,16 @@ int f_sys_dup3_x(struct event_filler_arguments *args)
* oldfd
*/
syscall_get_arguments_deprecated(args, 0, 1, &val);
res = val_to_ring(args, val, 0, false, 0);
fd = (int64_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);
res = val_to_ring(args, val, 0, false, 0);
fd = (int64_t) val;
res = val_to_ring(args, (int64_t)fd, 0, false, 0);
CHECK_RES(res);

/*
Expand Down

0 comments on commit 459b65c

Please sign in to comment.