From 0f0d78bbd62c41bfad3dbcbee8698251ad46eed9 Mon Sep 17 00:00:00 2001 From: Shaun Duncan Date: Mon, 23 Mar 2026 16:56:11 -0400 Subject: [PATCH] Allow link.OpenExecutable for files without executable bit set This change removes the restriction added in PR #1938 that requires file paths given to link.OpenExecutable() have the executable bit set. This restores the previous behvaior in versions prior to v0.21.0 while also preserving the new capabilities introduced in PR #1938. Signed-off-by: Shaun Duncan --- link/uprobe.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/link/uprobe.go b/link/uprobe.go index d53975d53..b38c98f4c 100644 --- a/link/uprobe.go +++ b/link/uprobe.go @@ -6,7 +6,6 @@ import ( "debug/elf" "errors" "fmt" - "io/fs" "os" "sync" @@ -35,8 +34,6 @@ var ( ErrNoSymbol = errors.New("not found") ) -const permExec fs.FileMode = 0111 - // Executable defines an executable program on the filesystem. type Executable struct { // Path of the executable on the filesystem. @@ -113,15 +110,10 @@ func OpenExecutable(path string) (*Executable, error) { return nil, fmt.Errorf("path cannot be empty") } - info, err := os.Stat(path) - if err != nil { + if _, err := os.Stat(path); err != nil { return nil, fmt.Errorf("stat executable: %w", err) } - if info.Mode()&permExec == 0 { - return nil, fmt.Errorf("file %s is not executable", path) - } - return &Executable{ path: path, cachedSymbols: make(map[string]symbol),