Skip to content

Commit

Permalink
chore(pkg/driver): do not fail if /sys/kernel/debug fails to be mounted.
Browse files Browse the repository at this point in the history
Also check if `/sys/kernel/debug/tracing` exists.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Nov 30, 2023
1 parent 610e851 commit 8683bc8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/driver/type/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"golang.org/x/net/context"
"k8s.io/utils/mount"

"github.com/falcosecurity/falcoctl/internal/utils"
"github.com/falcosecurity/falcoctl/pkg/output"
)

Expand All @@ -45,9 +46,15 @@ func (b *bpf) Cleanup(printer *output.Printer, _ string) error {
// since these releases still did not support raw tracepoints.
// BPF_PROG_TYPE_RAW_TRACEPOINT was introduced in 4.17 indeed:
// https://github.com/torvalds/linux/commit/c4f6699dfcb8558d138fe838f741b2c10f416cf9
exists, _ := utils.FileExists("/sys/kernel/debug/tracing")
if exists {
return nil
}
printer.Logger.Info("Mounting debugfs for bpf driver.")
mounter := mount.New("/bin/mount")
return mounter.Mount("debugfs", "/sys/kernel/debug", "debugfs", []string{"nodev"})
// We don't fail if this fails; let's try to build a probe anyway.
_ = mounter.Mount("debugfs", "/sys/kernel/debug", "debugfs", []string{"nodev"})
return nil
}

func (b *bpf) Load(_ *output.Printer, _ string, _ bool) error {
Expand Down

0 comments on commit 8683bc8

Please sign in to comment.