Skip to content

Commit 12a7e77

Browse files
committed
chore(ebpf): format apply based on the latest fix
1 parent d3fc3e1 commit 12a7e77

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

pkg/ebpf/c/common/buffer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ statfunc int events_perf_submit(program_data_t *p, long ret)
609609
}
610610
}
611611

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

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

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

642642
// inline bounds check to force compiler to use the register of size
643643
asm volatile("if %[size] < %[max_size] goto +1;\n"

pkg/ebpf/c/common/filtering.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ statfunc u64 match_data_filters(program_data_t *p, u8 index)
358358
u64 explicit_enable_policies = 0;
359359
u64 default_enable_policies = 0;
360360
// Determine policies that do not use any type of string filter (exact, prefix, suffix)
361-
u64 mask_no_str_filter_policies =
362-
~str_filter->exact_enabled & ~str_filter->prefix_enabled & ~str_filter->suffix_enabled;
361+
u64 mask_no_str_filter_policies = ~str_filter->exact_enabled & ~str_filter->prefix_enabled &
362+
~str_filter->suffix_enabled;
363363
void *filter_map = NULL;
364364

365365
// event ID

pkg/ebpf/c/tracee.bpf.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,10 @@ statfunc int find_modules_from_module_kset_list(program_data_t *p)
937937

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

946945
struct module_kobject *mod_kobj =
947946
(struct module_kobject *) container_of(n, struct module_kobject, kobj);
@@ -1033,8 +1032,8 @@ int lkm_seeker_modtree_loop(struct pt_regs *ctx)
10331032
break;
10341033
}
10351034

1036-
/* We have visited the node and its left subtree.
1037-
Now, it's right subtree's turn */
1035+
// We have visited the node and its left subtree.
1036+
// Now, it's right subtree's turn.
10381037
curr = BPF_CORE_READ(curr, rb_right);
10391038
}
10401039
}
@@ -1220,9 +1219,9 @@ int uprobe_lkm_seeker_submitter(struct pt_regs *ctx)
12201219
if (p.config->tracee_pid != trigger_pid)
12211220
return 0;
12221221

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

12281227
return 0;
@@ -1287,8 +1286,9 @@ int lkm_seeker_kset_tail(struct pt_regs *ctx)
12871286
if (ret < 0) {
12881287
tracee_log(ctx, BPF_LOG_LVL_WARN, BPF_LOG_ID_HID_KER_MOD, ret);
12891288
u32 flags = HISTORY_SCAN_FINISHED;
1290-
lkm_seeker_send_to_userspace(
1291-
(struct module *) HISTORY_SCAN_FAILURE, &flags, &p); // Report failure of history scan
1289+
1290+
// Report failure of history scan
1291+
lkm_seeker_send_to_userspace((struct module *) HISTORY_SCAN_FAILURE, &flags, &p);
12921292
return -1;
12931293
}
12941294

@@ -1362,8 +1362,8 @@ int lkm_seeker_new_mod_only_tail(struct pt_regs *ctx)
13621362
return -1;
13631363
}
13641364

1365-
struct module *mod =
1366-
(struct module *) start_scan_time; // Use the module address field as the start_scan_time
1365+
// Use the module address field as the start_scan_time
1366+
struct module *mod = (struct module *) start_scan_time;
13671367
u32 flags = NEW_MOD;
13681368
lkm_seeker_send_to_userspace(mod, &flags, &p);
13691369

@@ -2737,8 +2737,8 @@ int BPF_KPROBE(trace_security_socket_connect)
27372737
break;
27382738
case SYSCALL_SOCKETCALL:
27392739
arr_addr = (void *) get_syscall_arg2(p.event->task, task_regs, false);
2740-
bpf_probe_read_user(
2741-
&sockfd, sizeof(int), arr_addr); // fd is the first entry in the array
2740+
// fd is the first entry in the array
2741+
bpf_probe_read_user(&sockfd, sizeof(int), arr_addr);
27422742
stsb(args_buf, &sockfd, sizeof(int), 0);
27432743
break;
27442744
}
@@ -3195,12 +3195,8 @@ statfunc bool
31953195
filter_file_write_capture(program_data_t *p, struct file *file, io_data_t io_data, off_t start_pos)
31963196
{
31973197
return filter_file_path(p->ctx, &file_write_path_filter, file) ||
3198-
filter_file_type(p->ctx,
3199-
&file_type_filter,
3200-
CAPTURE_WRITE_TYPE_FILTER_IDX,
3201-
file,
3202-
io_data,
3203-
start_pos) ||
3198+
filter_file_type(
3199+
p->ctx, &file_type_filter, CAPTURE_WRITE_TYPE_FILTER_IDX, file, io_data, start_pos) ||
32043200
filter_file_fd(p->ctx, &file_type_filter, CAPTURE_WRITE_TYPE_FILTER_IDX, file);
32053201
}
32063202

pkg/ebpf/c/types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ typedef struct {
232232
typedef struct task_info {
233233
task_context_t context;
234234
syscall_data_t syscall_data;
235-
bool syscall_traced; // indicates that syscall_data is valid
236-
u8 container_state; // the state of the container the task resides in
237-
address_range_t
238-
stack; // stack area, only relevant for tasks that aren't group leaders (threads)
235+
bool syscall_traced; // indicates that syscall_data is valid
236+
u8 container_state; // the state of the container the task resides in
237+
address_range_t stack; // stack area, only relevant for tasks that aren't
238+
// group leaders (threads)
239239
} task_info_t;
240240

241241
typedef struct file_id {

0 commit comments

Comments
 (0)