-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: make policies config versioned
This extract the policies related fields from config_entry_t into a new separate struct (policies_config_t) which continues to be stored in the config_entry_t struct as well as the versioned policies_config_map. That is required to be able to access the right policies_config_t based on the policies version.
- Loading branch information
Showing
7 changed files
with
391 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ebpf | ||
|
||
import ( | ||
"unsafe" | ||
|
||
bpf "github.com/aquasecurity/libbpfgo" | ||
|
||
"github.com/aquasecurity/tracee/pkg/errfmt" | ||
"github.com/aquasecurity/tracee/pkg/policy" | ||
) | ||
|
||
const ( | ||
ConfigMap = "config_map" | ||
) | ||
|
||
// Config mirrors the C struct config_entry (config_entry_t). | ||
// | ||
// Order of fields is important, as it is used as a value for | ||
// the ConfigMap BPF map. | ||
type Config struct { | ||
TraceePid uint32 | ||
Options uint32 | ||
CgroupV1Hid uint32 | ||
_ uint16 // padding free for further use | ||
PoliciesVersion uint16 | ||
PoliciesConfig policy.PoliciesConfig | ||
} | ||
|
||
// UpdateBPF updates the ConfigMap BPF map with the current config. | ||
func (c *Config) UpdateBPF(bpfModule *bpf.Module) error { | ||
bpfConfigMap, err := bpfModule.GetMap(ConfigMap) | ||
if err != nil { | ||
return errfmt.WrapError(err) | ||
} | ||
|
||
cZero := uint32(0) | ||
if err = bpfConfigMap.Update(unsafe.Pointer(&cZero), unsafe.Pointer(c)); err != nil { | ||
return errfmt.WrapError(err) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.