Skip to content

Commit d2d89e2

Browse files
on aarch64 send exec events directly to userspace
On 68c2c8a we excluded failed execve* calls from being delivered to userspace, in order to get the binary that was executed and avoid errors/confusion. But on aarch64, it seems that we fail to save the exec event to a map, so the event is never delivered to userspace. So for the time being, send the exec events as soon as they arrive on aarch64, without checking if the call failed. (cherry picked from commit c118058)
1 parent 9a6dfe7 commit d2d89e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ebpf_prog/opensnitch-procs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ int tracepoint__syscalls_sys_enter_execve(struct trace_sys_enter_execve* ctx)
123123
}
124124
#endif
125125

126+
// FIXME: on aarch64 we fail to save the event to execMap, so send it to userspace here.
127+
#if defined(__aarch64__)
128+
bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, data, sizeof(*data));
129+
#else
126130
// in case of failure adding the item to the map, send it directly
127131
u64 pid_tgid = bpf_get_current_pid_tgid();
128132
if (bpf_map_update_elem(&execMap, &pid_tgid, data, BPF_ANY) != 0) {
@@ -132,6 +136,7 @@ int tracepoint__syscalls_sys_enter_execve(struct trace_sys_enter_execve* ctx)
132136
// Possible workaround: count -95 errors, and from userspace reinitialize the streamer if errors >= n-errors
133137
bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, data, sizeof(*data));
134138
}
139+
#endif
135140

136141
return 0;
137142
};
@@ -154,6 +159,9 @@ int tracepoint__syscalls_sys_enter_execveat(struct trace_sys_enter_execveat* ctx
154159
const char *argp={0};
155160
data->args_count = 0;
156161
data->args_partial = INCOMPLETE_ARGS;
162+
163+
// FIXME: on i386 arch, the following code fails with permission denied.
164+
#if !defined(__arm__) && !defined(__i386__)
157165
#pragma unroll
158166
for (int i = 0; i < MAX_ARGS; i++) {
159167
bpf_probe_read_user(&argp, sizeof(argp), &ctx->argv[i]);
@@ -164,7 +172,12 @@ int tracepoint__syscalls_sys_enter_execveat(struct trace_sys_enter_execveat* ctx
164172
}
165173
data->args_count++;
166174
}
175+
#endif
167176

177+
// FIXME: on aarch64 we fail to save the event to execMap, so send it to userspace here.
178+
#if defined(__aarch64__)
179+
bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, data, sizeof(*data));
180+
#else
168181
// in case of failure adding the item to the map, send it directly
169182
u64 pid_tgid = bpf_get_current_pid_tgid();
170183
if (bpf_map_update_elem(&execMap, &pid_tgid, data, BPF_ANY) != 0) {
@@ -174,6 +187,7 @@ int tracepoint__syscalls_sys_enter_execveat(struct trace_sys_enter_execveat* ctx
174187
// Possible workaround: count -95 errors, and from userspace reinitialize the streamer if errors >= n-errors
175188
bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, data, sizeof(*data));
176189
}
190+
#endif
177191

178192
return 0;
179193
};

0 commit comments

Comments
 (0)