Skip to content

Commit

Permalink
tracing: allow only one of kprobes/tracepoints/lsm
Browse files Browse the repository at this point in the history
For historic reasons, the tracing sensor has three different aspects:
kprobes, tracepoints, and (recently) lsm hooks.

Also for historic reasons, we did not allow tracepoints and kprobes in
the same policy.

With the addition of the LSM sensor
(8eb13e8), if a policy includes an lsm
section together with either a kprobe section or a tracepoint section,
the lsm section will be ignored.

This patch rejects policies that have more than one section of kprobes,
tracepoints, and lsm hooks in the policy.

A better solution would be to decouple the tracing sensor, and create
one sensor for kprobes, one for tracepoints, and one for lsm sensors.
See: #2706

Fixes: 8eb13e8

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
  • Loading branch information
kkourt committed Jul 22, 2024
1 parent 659704f commit 1225f7a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/sensors/tracing/policyhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ func (h policyHandler) PolicyHandler(

policyName := policy.TpName()
spec := policy.TpSpec()
if len(spec.KProbes) > 0 && len(spec.Tracepoints) > 0 {
return nil, errors.New("tracing policies with both kprobes and tracepoints are not currently supported")

sections := 0
if len(spec.KProbes) > 0 {
sections++
}
if len(spec.Tracepoints) > 0 {
sections++
}
if len(spec.LsmHooks) > 0 {
sections++
}
if sections > 1 {
return nil, errors.New("tracing policies with multiple sections of kprobes, tracepoints, or lsm hooks are currently not supported")
}

handler := eventhandler.GetCustomEventhandler(policy)
Expand Down

0 comments on commit 1225f7a

Please sign in to comment.