@@ -3,14 +3,12 @@ package ebpf
3
3
import (
4
4
gocontext "context"
5
5
"encoding/binary"
6
- "errors"
7
6
"fmt"
8
7
"os"
9
8
"strconv"
10
9
"strings"
11
10
"sync"
12
11
"sync/atomic"
13
- "syscall"
14
12
"unsafe"
15
13
16
14
"kernel.org/pub/linux/libs/security/libcap/cap"
@@ -384,17 +382,24 @@ func (t *Tracee) Init(ctx gocontext.Context) error {
384
382
usedClockID := traceetime .CLOCK_BOOTTIME
385
383
err = capabilities .GetInstance ().EBPF (
386
384
func () error {
385
+ // Since this code is running with sufficient capabilities, we can safely trust the result of `BPFHelperIsSupported`.
386
+ // If the helper is reported as supported (`supported == true`), it is assumed to be reliable for use.
387
+ // If `supported == false`, it indicates that the helper for getting BOOTTIME is not available.
388
+ // The `innerErr` provides information about errors that occurred during the check, regardless of whether `supported`
389
+ // is true or false.
390
+ // For a full explanation of the caveats and behavior, refer to:
391
+ // https://github.com/aquasecurity/libbpfgo/blob/eb576c71ece75930a693b8b0687c5d052a5dbd56/libbpfgo.go#L99-L119
387
392
supported , innerErr := bpf .BPFHelperIsSupported (bpf .BPFProgTypeKprobe , bpf .BPFFuncKtimeGetBootNs )
388
393
389
- // only report if operation not permitted
390
- if errors .Is (innerErr , syscall .EPERM ) {
391
- return innerErr
392
- }
393
-
394
- // If BPFFuncKtimeGetBootNs is not available, eBPF will generate events based on monotonic time.
394
+ // Use CLOCK_MONOTONIC only when the helper is explicitly unsupported
395
395
if ! supported {
396
396
usedClockID = traceetime .CLOCK_MONOTONIC
397
397
}
398
+
399
+ if innerErr != nil {
400
+ logger .Debugw ("Detect clock timing" , "warn" , innerErr )
401
+ }
402
+
398
403
return nil
399
404
})
400
405
if err != nil {
0 commit comments