Skip to content

Commit

Permalink
fix CHECK RES instances
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 committed Oct 5, 2023
1 parent 98d7df6 commit 10b13d3
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 @@ -1609,10 +1609,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 @@ -6091,16 +6088,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 @@ -6126,8 +6121,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 @@ -6136,8 +6130,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 @@ -6406,34 +6399,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 @@ -6824,34 +6805,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 @@ -7009,8 +6978,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 @@ -1508,8 +1508,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 @@ -1584,12 +1583,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 @@ -1649,8 +1646,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 @@ -1717,12 +1713,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 @@ -1764,23 +1758,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 10b13d3

Please sign in to comment.