Skip to content

Commit

Permalink
chore: add event_config alignment check
Browse files Browse the repository at this point in the history
declare a dummy event_config struct in bpf_alignchecker and check it in alignchecker.go

Close #108

Signed-off-by: Peihao Yang <[email protected]>
  • Loading branch information
Forsworns committed Jun 29, 2022
1 parent 7fd8213 commit 04262a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions bpf/alignchecker/bpf_alignchecker.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "include/vmlinux.h"
#include "include/api.h"
#include "lib/hubble_msg.h"
#include "process/retprobe_map.h"
#include "process/types/basic.h"

/* DECLARE declares a unique usage of the union or struct 'x' on the stack.
*
Expand Down Expand Up @@ -36,6 +38,7 @@ int main(void)
// from maps
DECLARE(struct, event, iter);
DECLARE(struct, execve_map_value, iter);
DECLARE(struct, event_config, iter);

return 0;
}
2 changes: 2 additions & 0 deletions pkg/alignchecker/alignchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cilium/tetragon/pkg/api/processapi"
"github.com/cilium/tetragon/pkg/api/testapi"
"github.com/cilium/tetragon/pkg/api/tracingapi"
"github.com/cilium/tetragon/pkg/sensors/exec/execvemap"

check "github.com/cilium/cilium/pkg/alignchecker"
Expand All @@ -29,6 +30,7 @@ func CheckStructAlignments(path string) error {
"msg_exit": {reflect.TypeOf(processapi.MsgExitEvent{})},
"msg_test": {reflect.TypeOf(testapi.MsgTestEvent{})},
"execve_map_value": {reflect.TypeOf(execvemap.ExecveValue{})},
"event_config": {reflect.TypeOf(tracingapi.EventConfig{})},
}
return check.CheckStructAlignments(path, toCheck, true)
}
16 changes: 8 additions & 8 deletions pkg/api/tracingapi/client_kprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ type KprobeArgs struct {
}

type EventConfig struct {
FuncId uint32
Arg [5]int32
ArgM [5]uint32
ArgTpCtxOff [5]uint32
Sigkill uint32
Syscall uint32
ArgReturnCopy int32
ArgReturn int32
FuncId uint32 `align:"func_id"`
Arg [5]int32 `align:"arg0"`
ArgM [5]uint32 `align:"arg0m"`
ArgTpCtxOff [5]uint32 `align:"t_arg0_ctx_off"`
Sigkill uint32 `align:"sigkill"`
Syscall uint32 `align:"syscall"`
ArgReturnCopy int32 `align:"argreturncopy"`
ArgReturn int32 `align:"argreturn"`
}

0 comments on commit 04262a5

Please sign in to comment.