Skip to content

Commit 00c7bd2

Browse files
committed
symbols_loaded: raise privileges when needed
1 parent 9826640 commit 00c7bd2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/events/derive/symbols_loaded.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ func (symbsLoadedGen *symbolsLoadedEventGenerator) deriveArgs(event trace.Event)
8080
soSyms, err := symbsLoadedGen.soLoader.GetExportedSymbols(loadingObjectInfo)
8181
if err != nil {
8282
// TODO: Create a warning upon this error when logger is available
83-
84-
// This error happens frequently in some environments, so we need to silence it to reduce spam.
83+
// TODO: rate limit frequent errors for overloaded envs
8584
if symbsLoadedGen.isDebug {
8685
return nil, err
8786
} else {
@@ -98,9 +97,9 @@ func (symbsLoadedGen *symbolsLoadedEventGenerator) deriveArgs(event trace.Event)
9897

9998
if len(exportedWatchSymbols) > 0 {
10099
return []interface{}{loadingObjectInfo.Path, exportedWatchSymbols}, nil
101-
} else {
102-
return nil, nil
103100
}
101+
102+
return nil, nil
104103
}
105104

106105
// isWhitelist check if a SO's path is in the whitelist given in initialization

pkg/utils/sharedobjs/host_symbols_loader.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package sharedobjs
22

33
import (
44
"debug/elf"
5+
6+
"github.com/aquasecurity/tracee/pkg/capabilities"
57
"github.com/hashicorp/golang-lru/simplelru"
68
)
79

@@ -98,7 +100,12 @@ func (soCache *dynamicSymbolsLRUCache) Add(obj ObjInfo, dynamicSymbols *dynamicS
98100

99101
// loadSharedObjectDynamicSymbols load all dynamic symbols of a shared object file in given path.
100102
func loadSharedObjectDynamicSymbols(path string) (*dynamicSymbols, error) {
101-
loadedObject, err := elf.Open(path)
103+
var loadedObject *elf.File
104+
err := capabilities.Caps.Required(func() error {
105+
var e error
106+
loadedObject, e = elf.Open(path)
107+
return e
108+
})
102109
if err != nil {
103110
return nil, err
104111
}

0 commit comments

Comments
 (0)