Skip to content

Commit

Permalink
tetragon: Mark some execve functions with __arg_ctx
Browse files Browse the repository at this point in the history
When calling this functions from other projects, they stay
global and it's important the verifier knows which argment
is context.

Adding also other argument related declaration tags.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Oct 19, 2024
1 parent 05716de commit f60dee8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions bpf/lib/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@ struct bpf_map_def {
#define DEBUG(__fmt, ...)
#endif

#ifdef __V61_BPF_PROG
#define __arg_ctx __attribute__((btf_decl_tag("arg:ctx")))
#define __arg_nonnull __attribute((btf_decl_tag("arg:nonnull")))
#define __arg_nullable __attribute((btf_decl_tag("arg:nullable")))
#define __arg_trusted __attribute((btf_decl_tag("arg:trusted")))
#define __arg_arena __attribute((btf_decl_tag("arg:arena")))
#else
#define __arg_ctx
#define __arg_nonnull
#define __arg_nullable
#define __arg_trusted
#define __arg_arena
#endif // __V61_BPF_PROG

#endif // _MSG_COMMON__
4 changes: 2 additions & 2 deletions bpf/process/bpf_execve_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ event_execve(struct trace_event_raw_sched_process_exec *ctx)
}

__attribute__((section("tracepoint"), used)) int
execve_rate(void *ctx)
execve_rate(void *ctx __arg_ctx)
{
struct msg_execve_event *msg;
__u32 zero = 0;
Expand Down Expand Up @@ -329,7 +329,7 @@ void update_mb_bitset(struct binary *bin)
* has already been collected, then send it to the perf buffer.
*/
__attribute__((section("tracepoint"), used)) int
execve_send(void *ctx)
execve_send(void *ctx __arg_ctx)
{
struct msg_execve_event *event;
struct execve_map_value *curr;
Expand Down

0 comments on commit f60dee8

Please sign in to comment.