Skip to content

Commit

Permalink
cleanup(drivers):driver inconsistencies CHECK_RES
Browse files Browse the repository at this point in the history
Signed-off-by: Everett Badeaux <[email protected]>

more check res additons

Signed-off-by: Everett Badeaux <[email protected]>

fix else statement

Signed-off-by: Everett Badeaux <[email protected]>

fix minimal errors

Signed-off-by: Everett Badeaux <[email protected]>

fix syntax errors

Signed-off-by: Everett Badeaux <[email protected]>

fix additional syntax errors

Signed-off-by: Everett Badeaux <[email protected]>

fix brace

Signed-off-by: Everett Badeaux <[email protected]>
  • Loading branch information
ecbadeaux authored and poiana committed Oct 6, 2023
1 parent 0b57876 commit 2bea7ba
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 783 deletions.
60 changes: 14 additions & 46 deletions driver/bpf/fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1610,10 +1610,7 @@ FILLER(sys_execveat_e, true)
}

res = bpf_push_s64_to_ring(data, (s64)fd);
if (res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);

/*
* pathname
Expand Down Expand Up @@ -6092,16 +6089,14 @@ FILLER(sys_copy_file_range_x, true)
*/
fdout = bpf_syscall_get_argument(data, 2);
res = bpf_push_s64_to_ring(data, fdout);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);

/*
* offout
*/
offout = bpf_syscall_get_argument(data, 3);
res = bpf_push_u64_to_ring(data, offout);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);

return res;
}
Expand All @@ -6127,8 +6122,7 @@ FILLER(sys_capset_x, true)
val = (unsigned long)cap.val;
#endif
res = bpf_push_u64_to_ring(data, capabilities_to_scap(val));
if(unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);

cap = _READ(cred->cap_permitted);
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
Expand All @@ -6137,8 +6131,7 @@ FILLER(sys_capset_x, true)
val = (unsigned long)cap.val;
#endif
res = bpf_push_u64_to_ring(data, capabilities_to_scap(val));
if(unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);

cap = _READ(cred->cap_effective);
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
Expand Down Expand Up @@ -6407,34 +6400,22 @@ FILLER(sched_prog_exec, false)
/* Parameter 2: exe (type: PT_CHARBUF) */
data->curarg_already_on_frame = true;
res = __bpf_val_to_ring(data, 0, exe_len, PT_CHARBUF, -1, false, KERNEL);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);

/* Parameter 3: args (type: PT_CHARBUFARRAY) */
data->curarg_already_on_frame = true;
res = __bpf_val_to_ring(data, 0, args_len - exe_len, PT_BYTEBUF, -1, false, KERNEL);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);
}
else
{
/* Parameter 2: exe (type: PT_CHARBUF) */
res = bpf_push_empty_param(data);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);

/* Parameter 3: args (type: PT_CHARBUFARRAY) */
res = bpf_push_empty_param(data);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);
}

/* Parameter 4: tid (type: PT_PID) */
Expand Down Expand Up @@ -6825,34 +6806,22 @@ FILLER(sched_prog_fork, false)
/* Parameter 2: exe (type: PT_CHARBUF) */
data->curarg_already_on_frame = true;
res = __bpf_val_to_ring(data, 0, exe_len, PT_CHARBUF, -1, false, KERNEL);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);

/* Parameter 3: args (type: PT_CHARBUFARRAY) */
data->curarg_already_on_frame = true;
res = __bpf_val_to_ring(data, 0, args_len - exe_len, PT_BYTEBUF, -1, false, KERNEL);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);
}
else
{
/* Parameter 2: exe (type: PT_CHARBUF) */
res = bpf_push_empty_param(data);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);

/* Parameter 3: args (type: PT_CHARBUFARRAY) */
res = bpf_push_empty_param(data);
if(res != PPM_SUCCESS)
{
return res;
}
CHECK_RES(res);
}

/* Parameter 4: tid (type: PT_PID) */
Expand Down Expand Up @@ -7010,8 +6979,7 @@ FILLER(sched_prog_fork_3, false)
/* Parameter 19: vtid (type: PT_PID) */
pid_t vtid = bpf_task_pid_vnr(child);
res = bpf_push_s64_to_ring(data, vtid);
if(res != PPM_SUCCESS)
return res;
CHECK_RES(res);

/* Parameter 20: vpid (type: PT_PID) */
pid_t vpid = bpf_task_tgid_vnr(child);
Expand Down
27 changes: 9 additions & 18 deletions driver/ppm_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,8 +1509,7 @@ int32_t parse_readv_writev_bufs(struct event_filler_arguments *args, const struc
size = retval;

res = val_to_ring(args, size, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
}

/*
Expand Down Expand Up @@ -1585,12 +1584,10 @@ int32_t parse_readv_writev_bufs(struct event_filler_arguments *args, const struc
bufsize,
false,
0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
} else {
res = val_to_ring(args, 0, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
}
}

Expand Down Expand Up @@ -1650,8 +1647,7 @@ int32_t compat_parse_readv_writev_bufs(struct event_filler_arguments *args, cons
size = retval;

res = val_to_ring(args, size, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
}

/*
Expand Down Expand Up @@ -1718,12 +1714,10 @@ int32_t compat_parse_readv_writev_bufs(struct event_filler_arguments *args, cons
bufsize,
false,
0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
} else {
res = val_to_ring(args, 0, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
}
}

Expand Down Expand Up @@ -1765,23 +1759,20 @@ int f_sys_autofill(struct event_filler_arguments *args)
val = args->args[evinfo->autofill_args[j].id];
#endif
res = val_to_ring(args, val, 0, true, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
} else if (evinfo->autofill_args[j].id == AF_ID_RETVAL) {
/*
* Return value
*/
retval = (int64_t)(long)syscall_get_return_value(current, args->regs);
res = val_to_ring(args, retval, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
} else if (evinfo->autofill_args[j].id == AF_ID_USEDEFAULT) {
/*
* Default Value
*/
res = val_to_ring(args, evinfo->autofill_args[j].default_val, 0, false, 0);
if (unlikely(res != PPM_SUCCESS))
return res;
CHECK_RES(res);
} else {
ASSERT(false);
}
Expand Down
Loading

0 comments on commit 2bea7ba

Please sign in to comment.