Skip to content

Commit

Permalink
pkg/api: move MsgGenericCred from tracingapi to processapi
Browse files Browse the repository at this point in the history
This moves the definition of MsgGenericCred from tracinapi to
processapi. No logic change here.

This is preparation for next patches where we will use the
MsgGenericCred to send execve and clone event from bpf.

Then at the end we will remove the MsgGenericCredMinimal that was
used a temporary solution to improve things, and make Tetragon
send full creds during execve and clone.

Signed-off-by: Djalal Harouni <[email protected]>
  • Loading branch information
tixxdz committed Mar 30, 2024
1 parent 3631ae2 commit f1e1854
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/alignchecker/alignchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func CheckStructAlignments(pathToObj string) error {
"msg_execve_key": {processapi.MsgExecveKey{}},
"execve_map_value": {execvemap.ExecveValue{}},
"msg_cgroup_event": {processapi.MsgCgroupEvent{}},
"msg_cred": {tracingapi.MsgGenericCred{}},
"msg_cred": {processapi.MsgGenericCred{}},
"msg_cred_minimal": {processapi.MsgGenericCredMinimal{}},

// configuration
Expand Down
15 changes: 15 additions & 0 deletions pkg/api/processapi/processapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ type MsgK8sUnix struct {
Docker string
}

type MsgGenericCred struct {
Uid uint32
Gid uint32
Suid uint32
Sgid uint32
Euid uint32
Egid uint32
FSuid uint32
FSgid uint32
SecureBits uint32
Pad uint32
Cap MsgCapabilities
UserNs MsgUserNamespace
}

type MsgGenericCredMinimal struct {
Uid uint32
Gid uint32
Expand Down
15 changes: 0 additions & 15 deletions pkg/api/tracingapi/client_kprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,6 @@ func (m MsgGenericKprobeArgNetDev) IsReturnArg() bool {
return m.Index == ReturnArgIndex
}

type MsgGenericCred struct {
Uid uint32
Gid uint32
Suid uint32
Sgid uint32
Euid uint32
Egid uint32
FSuid uint32
FSgid uint32
SecureBits uint32
Pad uint32
Cap processapi.MsgCapabilities
UserNs processapi.MsgUserNamespace
}

type MsgGenericKprobeArgCred struct {
Index uint64
Uid uint32
Expand Down
6 changes: 3 additions & 3 deletions pkg/sensors/tracing/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io"

"github.com/cilium/tetragon/pkg/api/dataapi"
"github.com/cilium/tetragon/pkg/api/tracingapi"
processapi "github.com/cilium/tetragon/pkg/api/processapi"
api "github.com/cilium/tetragon/pkg/api/tracingapi"
gt "github.com/cilium/tetragon/pkg/generictypes"
"github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1"
Expand Down Expand Up @@ -74,7 +74,7 @@ func getTracepointMetaValue(arg *v1alpha1.KProbeArg) int {
return 0
}

func getArg(r *bytes.Reader, a argPrinter) tracingapi.MsgGenericKprobeArg {
func getArg(r *bytes.Reader, a argPrinter) api.MsgGenericKprobeArg {
var err error

switch a.ty {
Expand Down Expand Up @@ -176,7 +176,7 @@ func getArg(r *bytes.Reader, a argPrinter) tracingapi.MsgGenericKprobeArg {
arg.Label = a.label
return arg
case gt.GenericCredType:
var cred api.MsgGenericCred
var cred processapi.MsgGenericCred
var arg api.MsgGenericKprobeArgCred

err := binary.Read(r, binary.LittleEndian, &cred)
Expand Down

0 comments on commit f1e1854

Please sign in to comment.