Skip to content

Commit

Permalink
chore: format apply based on the latest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
geyslan committed Feb 12, 2025
1 parent c0c1cb7 commit c3a7017
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
8 changes: 4 additions & 4 deletions pkg/ebpf/c/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ statfunc int events_perf_submit(program_data_t *p, long ret)
}
}

u32 size = sizeof(event_context_t) + sizeof(u8) +
p->event->args_buf.offset; // context + argnum + arg buffer size
// context + argnum + arg buffer size
u32 size = sizeof(event_context_t) + sizeof(u8) + p->event->args_buf.offset;

// inline bounds check to force compiler to use the register of size
asm volatile("if %[size] < %[max_size] goto +1;\n"
Expand All @@ -636,8 +636,8 @@ statfunc int events_perf_submit(program_data_t *p, long ret)

statfunc int signal_perf_submit(void *ctx, controlplane_signal_t *sig)
{
u32 size =
sizeof(u32) + sizeof(u8) + sig->args_buf.offset; // signal id + argnum + arg buffer size
// signal id + argnum + arg buffer size
u32 size = sizeof(u32) + sizeof(u8) + sig->args_buf.offset;

// inline bounds check to force compiler to use the register of size
asm volatile("if %[size] < %[max_size] goto +1;\n"
Expand Down
4 changes: 2 additions & 2 deletions pkg/ebpf/c/common/filtering.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ statfunc u64 match_data_filters(program_data_t *p, u8 index)
u64 explicit_enable_policies = 0;
u64 default_enable_policies = 0;
// Determine policies that do not use any type of string filter (exact, prefix, suffix)
u64 mask_no_str_filter_policies =
~str_filter->exact_enabled & ~str_filter->prefix_enabled & ~str_filter->suffix_enabled;
u64 mask_no_str_filter_policies = ~str_filter->exact_enabled & ~str_filter->prefix_enabled &
~str_filter->suffix_enabled;
void *filter_map = NULL;

// event ID
Expand Down
35 changes: 16 additions & 19 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,9 @@ statfunc int find_modules_from_module_kset_list(program_data_t *p)

#pragma unroll
for (int i = 0; i < MAX_NUM_MODULES; i++) {
if (BPF_CORE_READ(n, name) ==
NULL) { // Without this the list seems infinite. Also, using pos
// here seems incorrect as it starts from a weird member
// Without this the list seems infinite.
// Also, using pos here seems incorrect as it starts from a weird member.
if (BPF_CORE_READ(n, name) == NULL) {
return 0;
}

Expand Down Expand Up @@ -1034,7 +1034,7 @@ int lkm_seeker_modtree_loop(struct pt_regs *ctx)
}

/* We have visited the node and its left subtree.
Now, it's right subtree's turn */
Now, it's right subtree's turn */
curr = BPF_CORE_READ(curr, rb_right);
}
}
Expand Down Expand Up @@ -1220,9 +1220,9 @@ int uprobe_lkm_seeker_submitter(struct pt_regs *ctx)
if (p.config->tracee_pid != trigger_pid)
return 0;

u32 flags =
((u32) received_flags) | HIDDEN_MODULE; // Convert to 32bit and turn on the bit that will
// cause it to be sent as an event to the user
// Convert to 32bit and turn on the bit that will cause it to be sent as an
// event to the user.
u32 flags = ((u32) received_flags) | HIDDEN_MODULE;
lkm_seeker_send_to_userspace((struct module *) mod_address, &flags, &p);

return 0;
Expand Down Expand Up @@ -1287,8 +1287,9 @@ int lkm_seeker_kset_tail(struct pt_regs *ctx)
if (ret < 0) {
tracee_log(ctx, BPF_LOG_LVL_WARN, BPF_LOG_ID_HID_KER_MOD, ret);
u32 flags = HISTORY_SCAN_FINISHED;
lkm_seeker_send_to_userspace(
(struct module *) HISTORY_SCAN_FAILURE, &flags, &p); // Report failure of history scan

// Report failure of history scan
lkm_seeker_send_to_userspace((struct module *) HISTORY_SCAN_FAILURE, &flags, &p);
return -1;
}

Expand Down Expand Up @@ -1362,8 +1363,8 @@ int lkm_seeker_new_mod_only_tail(struct pt_regs *ctx)
return -1;
}

struct module *mod =
(struct module *) start_scan_time; // Use the module address field as the start_scan_time
// Use the module address field as the start_scan_time
struct module *mod = (struct module *) start_scan_time;
u32 flags = NEW_MOD;
lkm_seeker_send_to_userspace(mod, &flags, &p);

Expand Down Expand Up @@ -2737,8 +2738,8 @@ int BPF_KPROBE(trace_security_socket_connect)
break;
case SYSCALL_SOCKETCALL:
arr_addr = (void *) get_syscall_arg2(p.event->task, task_regs, false);
bpf_probe_read_user(
&sockfd, sizeof(int), arr_addr); // fd is the first entry in the array
// fd is the first entry in the array
bpf_probe_read_user(&sockfd, sizeof(int), arr_addr);
stsb(args_buf, &sockfd, sizeof(int), 0);
break;
}
Expand Down Expand Up @@ -3195,12 +3196,8 @@ statfunc bool
filter_file_write_capture(program_data_t *p, struct file *file, io_data_t io_data, off_t start_pos)
{
return filter_file_path(p->ctx, &file_write_path_filter, file) ||
filter_file_type(p->ctx,
&file_type_filter,
CAPTURE_WRITE_TYPE_FILTER_IDX,
file,
io_data,
start_pos) ||
filter_file_type(
p->ctx, &file_type_filter, CAPTURE_WRITE_TYPE_FILTER_IDX, file, io_data, start_pos) ||
filter_file_fd(p->ctx, &file_type_filter, CAPTURE_WRITE_TYPE_FILTER_IDX, file);
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/ebpf/c/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ typedef struct {
typedef struct task_info {
task_context_t context;
syscall_data_t syscall_data;
bool syscall_traced; // indicates that syscall_data is valid
u8 container_state; // the state of the container the task resides in
address_range_t
stack; // stack area, only relevant for tasks that aren't group leaders (threads)
bool syscall_traced; // indicates that syscall_data is valid
u8 container_state; // the state of the container the task resides in
address_range_t stack; // stack area, only relevant for tasks that aren't
// group leaders (threads)
} task_info_t;

typedef struct file_id {
Expand Down

0 comments on commit c3a7017

Please sign in to comment.