mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
disable (process) ebpf events when to many errors
if an invalid opensnitch-procs.o module was loaded, we were flooding the log with errors. In these cases stop processing events after 20 errors (random, we should have no errors). This may occur if the module is malformed (valid .o ebpf module but different structs, etc), or when loading modules from other versions. Closes: #1099 #1082
This commit is contained in:
parent
7442bec96f
commit
0a911ef791
1 changed files with 15 additions and 0 deletions
|
@ -158,6 +158,17 @@ func initPerfMap(mod *elf.Module) error {
|
|||
|
||||
func streamEventsWorker(id int, chn chan []byte, lost chan uint64, kernelEvents chan interface{}) {
|
||||
var event execEvent
|
||||
errors := 0
|
||||
maxErrors := 20 // we should have no errors.
|
||||
tooManyErrors := func() bool {
|
||||
errors++
|
||||
if errors > maxErrors {
|
||||
log.Error("[eBPF events] too many errors parsing events from kernel")
|
||||
log.Error("verify that you're using the correct eBPF modules for this version (%s)", core.Version)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-ctxTasks.Done():
|
||||
|
@ -167,6 +178,10 @@ func streamEventsWorker(id int, chn chan []byte, lost chan uint64, kernelEvents
|
|||
case d := <-chn:
|
||||
if err := binary.Read(bytes.NewBuffer(d), hostByteOrder, &event); err != nil {
|
||||
log.Debug("[eBPF events #%d] error: %s", id, err)
|
||||
if tooManyErrors() {
|
||||
goto Exit
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue