Skip to content

Commit 67941b6

Browse files
authored
derive: fix libs whitelist of symbols_loaded (#2048)
Add whitelist of architectures libraries directories.
1 parent 9b31c56 commit 67941b6

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

pkg/events/derive/symbols_loaded.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ func SymbolsLoaded(soLoader sharedobjs.DynamicSymbolsLoader, watchedSymbols []st
1616

1717
// Most specific paths should be at the top, to prevent bugs with iterations over the list
1818
var knownLibrariesDirs = []string{
19-
"/usr/lib/x86_64-linux-gnu/",
2019
"/usr/lib64/",
2120
"/usr/lib/",
2221
"/lib64/",
2322
"/lib/",
2423
}
2524

25+
var knownArchitectureDirs = []string{
26+
"x86_64-linux-gnu",
27+
"aarch64-linux-gnu",
28+
"i386-linux-gnu",
29+
"i686-linux-gnu",
30+
"", // non-specific architecture dir
31+
}
32+
2633
// symbolsLoadedEventGenerator is responsible of generating event if shared object loaded to a process
2734
// export one or more from given watched sybmols.
2835
type symbolsLoadedEventGenerator struct {
@@ -98,9 +105,15 @@ func (symbsLoadedGen *symbolsLoadedEventGenerator) isWhitelist(soPath string) bo
98105
if len(symbsLoadedGen.librariesWhitelist) > 0 {
99106
for _, libsDirectory := range knownLibrariesDirs {
100107
if strings.HasPrefix(soPath, libsDirectory) {
101-
for _, wlLib := range symbsLoadedGen.librariesWhitelist {
102-
if strings.HasPrefix(soPath, path.Join(libsDirectory, wlLib)) {
103-
return true
108+
for _, archDir := range knownArchitectureDirs {
109+
archLibDir := path.Join(libsDirectory, archDir)
110+
if strings.HasPrefix(soPath, archLibDir) {
111+
for _, wlLib := range symbsLoadedGen.librariesWhitelist {
112+
if strings.HasPrefix(soPath, path.Join(archLibDir, wlLib)) {
113+
return true
114+
}
115+
}
116+
break
104117
}
105118
}
106119
break

0 commit comments

Comments
 (0)