Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat go binaries without offsets as generic (1.9 branch patch) #1477

Merged
merged 3 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Treat go binaries without offsets as generic
There is a small corner case in which we detect no go offsets in a
target executable, but if that executable happens to have a ".gosyms"
section, we will end up classifying it as a Go executable, causing
issues. We attach an error in this case to have the attacher treat it as
a generic executable.
  • Loading branch information
rafaelroquetto committed Dec 20, 2024
commit 783f8209ee133056ed4830214ad0254bcf1ec5cf
8 changes: 8 additions & 0 deletions pkg/internal/discover/typer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package discover

import (
"fmt"
"log/slog"
"strings"

Expand Down Expand Up @@ -146,6 +147,13 @@ func (t *typer) asInstrumentable(execElf *exec.FileInfo) ebpf.Instrumentable {

detectedType := exec.FindProcLanguage(execElf.Pid, execElf.ELF, execElf.CmdExePath)

if detectedType == svc.InstrumentableGolang && err == nil {
log.Warn("ELF binary appears to be a Go program, but no offsets were found",
"comm", execElf.CmdExePath, "pid", execElf.Pid)

err = fmt.Errorf("could not find any Go offsets in Go binary %s", execElf.CmdExePath)
}

log.Debug("instrumented", "comm", execElf.CmdExePath, "pid", execElf.Pid,
"child", child, "language", detectedType.String())
// Return the instrumentable without offsets, as it is identified as a generic
Expand Down