Skip to content

Commit

Permalink
manual offset
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed May 13, 2024
1 parent e419c09 commit 6b6d46d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
25 changes: 25 additions & 0 deletions pkg/security/probe/constantfetch/quirks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:build linux

// Package constantfetch holds constantfetch related files
package constantfetch

import "github.com/DataDog/datadog-agent/pkg/security/ebpf/kernel"

// GetRHEL93MMapDelta returns the potential offset in `sys_enter_mmap` fields when reading from the tracepoint
// format
func GetRHEL93MMapDelta(kv *kernel.Version) uint64 {
switch {
// rh 9.3 is completely buggy.. the tracepoint format of `sys_enter_mmap` is not the actual format..
// bpftrace is as confused as us on this
// this check is to fix this manually
case kv.IsInRangeCloseOpen(kernel.Kernel5_14, kernel.Kernel5_15) && kv.IsRH9_3Kernel():
return 8
default:
return 0
}
}
8 changes: 4 additions & 4 deletions pkg/security/probe/probe_ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1560,19 +1560,19 @@ func NewEBPFProbe(probe *Probe, config *config.Config, opts Opts, wmeta optional
},
manager.ConstantEditor{
Name: constantfetch.OffsetNameSysMmapOff,
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "off", 56),
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "off", 56) + constantfetch.GetRHEL93MMapDelta(p.kernelVersion),
},
manager.ConstantEditor{
Name: constantfetch.OffsetNameSysMmapLen,
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "len", 24),
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "len", 24) + constantfetch.GetRHEL93MMapDelta(p.kernelVersion),
},
manager.ConstantEditor{
Name: constantfetch.OffsetNameSysMmapProt,
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "prot", 32),
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "prot", 32) + constantfetch.GetRHEL93MMapDelta(p.kernelVersion),
},
manager.ConstantEditor{
Name: constantfetch.OffsetNameSysMmapFlags,
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "flags", 40),
Value: constantfetch.ReadTracepointFieldOffsetWithFallback("syscalls/sys_enter_mmap", "flags", 40) + constantfetch.GetRHEL93MMapDelta(p.kernelVersion),
},
)

Expand Down

0 comments on commit 6b6d46d

Please sign in to comment.