Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package inspektor-gadget for 
openSUSE:Factory checked in at 2026-06-05 15:03:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/inspektor-gadget (Old)
 and      /work/SRC/openSUSE:Factory/.inspektor-gadget.new.2375 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "inspektor-gadget"

Fri Jun  5 15:03:19 2026 rev:32 rq:1357240 version:0.53.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/inspektor-gadget/inspektor-gadget.changes        
2026-06-02 16:08:12.940588890 +0200
+++ 
/work/SRC/openSUSE:Factory/.inspektor-gadget.new.2375/inspektor-gadget.changes  
    2026-06-05 15:03:44.144836799 +0200
@@ -1,0 +2,8 @@
+Fri Jun 05 06:11:32 UTC 2026 - Johannes Kastl 
<[email protected]>
+
+- Update to version 0.53.1:
+  * Bug fixes
+    - [BACKPORT] security hardening fixes for USDT/uprobe
+      ELF/ld.so.cache parsing by @alban in #5547
+
+-------------------------------------------------------------------

Old:
----
  inspektor-gadget-0.53.0.obscpio

New:
----
  inspektor-gadget-0.53.1.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ inspektor-gadget.spec ++++++
--- /var/tmp/diff_new_pack.GQjYo1/_old  2026-06-05 15:03:45.988913144 +0200
+++ /var/tmp/diff_new_pack.GQjYo1/_new  2026-06-05 15:03:45.992913309 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           inspektor-gadget
-Version:        0.53.0
+Version:        0.53.1
 Release:        0
 Summary:        A eBPF tool and systems inspection framework
 License:        Apache-2.0

++++++ _service ++++++
--- /var/tmp/diff_new_pack.GQjYo1/_old  2026-06-05 15:03:46.076916787 +0200
+++ /var/tmp/diff_new_pack.GQjYo1/_new  2026-06-05 15:03:46.080916953 +0200
@@ -3,7 +3,7 @@
     <param 
name="url">https://github.com/inspektor-gadget/inspektor-gadget</param>
     <param name="scm">git</param>
     <param name="exclude">.git</param>
-    <param name="revision">v0.53.0</param>
+    <param name="revision">v0.53.1</param>
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="versionrewrite-pattern">v(.*)</param>
     <param name="changesgenerate">enable</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.GQjYo1/_old  2026-06-05 15:03:46.128918940 +0200
+++ /var/tmp/diff_new_pack.GQjYo1/_new  2026-06-05 15:03:46.132919105 +0200
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/inspektor-gadget/inspektor-gadget</param>
-              <param 
name="changesrevision">40398a64e15b96366215dbd05e0a52b969a4a0c1</param></service></servicedata>
+              <param 
name="changesrevision">ec69da2e00c39bc43f389f943899e5ff9c7b011a</param></service></servicedata>
 (No newline at EOF)
 

++++++ inspektor-gadget-0.53.0.obscpio -> inspektor-gadget-0.53.1.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/inspektor-gadget-0.53.0/pkg/operators/ebpf/extrainfo.go 
new/inspektor-gadget-0.53.1/pkg/operators/ebpf/extrainfo.go
--- old/inspektor-gadget-0.53.0/pkg/operators/ebpf/extrainfo.go 2026-06-01 
15:47:32.000000000 +0200
+++ new/inspektor-gadget-0.53.1/pkg/operators/ebpf/extrainfo.go 2026-06-02 
14:33:32.000000000 +0200
@@ -16,7 +16,6 @@
 
 import (
        "bytes"
-       "debug/elf"
        "encoding/json"
        "fmt"
        "strings"
@@ -27,6 +26,7 @@
        "github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-service/api"
        "github.com/inspektor-gadget/inspektor-gadget/pkg/operators"
        graphutils 
"github.com/inspektor-gadget/inspektor-gadget/pkg/utils/ebpf2graph"
+       "github.com/inspektor-gadget/inspektor-gadget/pkg/utils/safeelf"
 )
 
 type extraInfoMap struct {
@@ -48,7 +48,7 @@
 }
 
 func (i *ebpfInstance) addExtraInfo(gadgetCtx operators.GadgetContext) error {
-       ef, err := elf.NewFile(bytes.NewReader(i.program))
+       ef, err := safeelf.NewFile(bytes.NewReader(i.program))
        if err != nil {
                return fmt.Errorf("parsing elf file: %w", err)
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inspektor-gadget-0.53.0/pkg/symbolizer/table.go 
new/inspektor-gadget-0.53.1/pkg/symbolizer/table.go
--- old/inspektor-gadget-0.53.0/pkg/symbolizer/table.go 2026-06-01 
15:47:32.000000000 +0200
+++ new/inspektor-gadget-0.53.1/pkg/symbolizer/table.go 2026-06-02 
14:33:32.000000000 +0200
@@ -20,6 +20,8 @@
        "os"
        "slices"
        "time"
+
+       "github.com/inspektor-gadget/inspektor-gadget/pkg/utils/safeelf"
 )
 
 const (
@@ -53,7 +55,7 @@
 func NewSymbolTableFromFile(file *os.File) (*SymbolTable, error) {
        var symbols []*Symbol
 
-       elfFile, err := elf.NewFile(file)
+       elfFile, err := safeelf.NewFile(file)
        if err != nil {
                return nil, fmt.Errorf("parsing ELF file: %w", err)
        }
@@ -84,9 +86,9 @@
                        Size:  sym.Size,
                })
                symbolCount++
-       }
-       if symbolCount > MaxSymbolCount {
-               return nil, fmt.Errorf("too many symbols: %d", symbolCount)
+               if symbolCount > MaxSymbolCount {
+                       return nil, fmt.Errorf("too many symbols: %d (exceeds 
limit %d)", symbolCount, MaxSymbolCount)
+               }
        }
        slices.SortFunc(symbols, func(a, b *Symbol) int {
                if a.Value < b.Value {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inspektor-gadget-0.53.0/pkg/uprobetracer/bytes.go 
new/inspektor-gadget-0.53.1/pkg/uprobetracer/bytes.go
--- old/inspektor-gadget-0.53.0/pkg/uprobetracer/bytes.go       2026-06-01 
15:47:32.000000000 +0200
+++ new/inspektor-gadget-0.53.1/pkg/uprobetracer/bytes.go       2026-06-02 
14:33:32.000000000 +0200
@@ -16,30 +16,62 @@
 
 import (
        "bytes"
-       "encoding/binary"
        "errors"
        "unsafe"
 )
 
-func readFromBytes[T any](obj *T, rawData []byte) error {
+// plainDataStruct constrains types to fixed-size structs containing only
+// numeric fields (int32, uint32, uint64, fixed-size arrays of int8, etc.).
+// These types have no pointers, strings, slices, or interfaces, making them
+// safe to reinterpret directly from a byte buffer without serialization.
+// Adding a new type here requires verifying it meets these criteria.
+type plainDataStruct interface {
+       ldCache1 | ldCache1Entry | ldCache2 | ldCache2Entry
+}
+
+// reinterpretBytes interprets rawData as a value of type T using direct memory
+// reinterpretation (equivalent to a C memcpy/cast). This assumes:
+//   - T satisfies plainDataStruct (only fixed-size numeric fields)
+//   - rawData is in native byte order (matching the host architecture)
+//   - len(rawData) == unsafe.Sizeof(T)
+//
+// This is used instead of encoding/binary.Read for performance: binary.Read
+// uses reflection and allocates intermediate buffers, which is significantly
+// slower when called in tight loops (e.g., parsing ~700K ld.so.cache entries).
+func reinterpretBytes[T plainDataStruct](obj *T, rawData []byte) error {
        if int(unsafe.Sizeof(*obj)) != len(rawData) {
                return errors.New("reading from bytes: length mismatched")
        }
-       buffer := bytes.NewBuffer(rawData)
-       err := binary.Read(buffer, binary.NativeEndian, obj)
-       if err != nil {
-               return err
-       }
+       *obj = *(*T)(unsafe.Pointer(&rawData[0]))
        return nil
 }
 
+// readStringFromBytes reads a null-terminated string starting at startPos in
+// data. Returns "" if startPos is out of bounds or no null terminator is 
found.
+// Uses bytes.IndexByte for O(n) performance.
 func readStringFromBytes(data []byte, startPos uint32) string {
-       res := ""
-       for i := startPos; i < uint32(len(data)); i++ {
-               if data[i] == 0 {
-                       return res
-               }
-               res += string(data[i])
+       if startPos >= uint32(len(data)) {
+               return ""
+       }
+       end := bytes.IndexByte(data[startPos:], 0)
+       if end == -1 {
+               return ""
+       }
+       return string(data[startPos : startPos+uint32(end)])
+}
+
+// matchStringInBytes checks whether the null-terminated string at startPos in
+// data begins with prefix. This avoids allocating a Go string for entries that
+// don't match, reducing GC pressure when scanning large caches.
+// Note: string([]byte) in a comparison is optimized by the Go compiler to
+// avoid allocation when the result is not stored.
+func matchStringInBytes(data []byte, startPos uint32, prefix string) bool {
+       if startPos >= uint32(len(data)) {
+               return false
+       }
+       remaining := data[startPos:]
+       if uint32(len(remaining)) < uint32(len(prefix)) {
+               return false
        }
-       return ""
+       return string(remaining[:len(prefix)]) == prefix
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/inspektor-gadget-0.53.0/pkg/uprobetracer/ldcache_parser.go 
new/inspektor-gadget-0.53.1/pkg/uprobetracer/ldcache_parser.go
--- old/inspektor-gadget-0.53.0/pkg/uprobetracer/ldcache_parser.go      
2026-06-01 15:47:32.000000000 +0200
+++ new/inspektor-gadget-0.53.1/pkg/uprobetracer/ldcache_parser.go      
2026-06-02 14:33:32.000000000 +0200
@@ -18,7 +18,6 @@
        "bytes"
        "errors"
        "fmt"
-       "strings"
        "unsafe"
 
        "github.com/inspektor-gadget/inspektor-gadget/pkg/utils/secureopen"
@@ -63,48 +62,60 @@
        // ld.so.cache is typically less than 200 KiB.
        // 16 MiB should be enough.
        ldCacheMaxSize = int64(16 * 1024 * 1024)
-)
 
-type ldEntry struct {
-       Key   string
-       Value string
-}
+       // A real ld.so.cache has only a handful of entries per library name
+       // (typically 1–3 across architecture variants). Cap results to bound
+       // memory usage when parsing a crafted file.
+       ldCacheMaxResults = 64
+)
 
-func readCacheFormat1(data []byte) []ldEntry {
-       var ldEntries []ldEntry
+func readCacheFormat1(data []byte, libraryPrefix string) []string {
+       var results []string
 
-       ldCache := ldCache1{}
        if uint32(len(data)) <= ldCache1Size {
                return nil
        }
-       err := readFromBytes(&ldCache, data[:ldCache1Size])
+       ldCache := ldCache1{}
+       err := reinterpretBytes(&ldCache, data[:ldCache1Size])
        if err != nil {
                return nil
        }
        ldEntriesOffset := ldCache1Size
-       ldStringsOffset := ldCache1Size + ldCache1EntrySize*ldCache.EntryCount
+       // Cap entry count based on actual file size to prevent excessive 
iteration.
+       maxEntries := (uint32(len(data)) - ldEntriesOffset) / ldCache1EntrySize
+       if ldCache.EntryCount > maxEntries {
+               ldCache.EntryCount = maxEntries
+       }
+       ldStringsOffset := ldEntriesOffset + 
ldCache1EntrySize*ldCache.EntryCount
        for i := uint32(0); i < ldCache.EntryCount; i++ {
                entryOffset := ldEntriesOffset + i*ldCache1EntrySize
                entry := ldCache1Entry{}
                if uint32(len(data)) <= entryOffset+ldCache1EntrySize {
                        return nil
                }
-               err := readFromBytes(&entry, 
data[entryOffset:entryOffset+ldCache1EntrySize])
+               err := reinterpretBytes(&entry, 
data[entryOffset:entryOffset+ldCache1EntrySize])
                if err != nil {
                        return nil
                }
                keyOffset := ldStringsOffset + entry.Key
-               valueOffset := ldStringsOffset + entry.Value
-               key := readStringFromBytes(data, keyOffset)
-               value := readStringFromBytes(data, valueOffset)
-               ldEntries = append(ldEntries, ldEntry{key, value})
+               if matchStringInBytes(data, keyOffset, libraryPrefix) {
+                       valueOffset := ldStringsOffset + entry.Value
+                       value := readStringFromBytes(data, valueOffset)
+                       results = append(results, value)
+                       if len(results) >= ldCacheMaxResults {
+                               break
+                       }
+               }
        }
-       return ldEntries
+       return results
 }
 
-func readCacheFormat2(data []byte) []ldEntry {
-       var ldEntries []ldEntry
+func readCacheFormat2(data []byte, libraryPrefix string) []string {
+       var results []string
 
+       if len(data) < len(cache2Header) {
+               return nil
+       }
        if !bytes.Equal([]byte(cache2Header), data[:len(cache2Header)]) {
                return nil
        }
@@ -112,28 +123,37 @@
        if uint32(len(data)) <= ldCache2Size {
                return nil
        }
-       err := readFromBytes(&ldCache, data[:ldCache2Size])
+       err := reinterpretBytes(&ldCache, data[:ldCache2Size])
        if err != nil {
                return nil
        }
        ldEntriesOffset := ldCache2Size
+       // Cap entry count based on actual file size to prevent excessive 
iteration.
+       maxEntries := (uint32(len(data)) - ldEntriesOffset) / ldCache2EntrySize
+       if ldCache.EntryCount > maxEntries {
+               ldCache.EntryCount = maxEntries
+       }
        for i := uint32(0); i < ldCache.EntryCount; i++ {
                entryOffset := ldEntriesOffset + i*ldCache2EntrySize
                entry := ldCache2Entry{}
                if uint32(len(data)) <= entryOffset+ldCache2EntrySize {
                        return nil
                }
-               err := readFromBytes(&entry, 
data[entryOffset:entryOffset+ldCache2EntrySize])
+               err := reinterpretBytes(&entry, 
data[entryOffset:entryOffset+ldCache2EntrySize])
                if err != nil {
                        return nil
                }
                keyOffset := entry.Key
-               valueOffset := entry.Value
-               key := readStringFromBytes(data, keyOffset)
-               value := readStringFromBytes(data, valueOffset)
-               ldEntries = append(ldEntries, ldEntry{key, value})
+               if matchStringInBytes(data, keyOffset, libraryPrefix) {
+                       valueOffset := entry.Value
+                       value := readStringFromBytes(data, valueOffset)
+                       results = append(results, value)
+                       if len(results) >= ldCacheMaxResults {
+                               break
+                       }
+               }
        }
-       return ldEntries
+       return results
 }
 
 // simulate the loader's behaviour, find library path in containers' 
`/etc/ld.so.cache`.
@@ -146,39 +166,34 @@
        }
        ldCacheFileSize := uint32(len(ldCacheFile))
 
-       var ldEntries []ldEntry
        var filteredLibraries []string
+       libraryPrefix := libraryName + ".so"
 
-       if bytes.Equal([]byte(cache1Header), ldCacheFile[:len(cache1Header)]) {
+       if len(ldCacheFile) >= len(cache1Header) && 
bytes.Equal([]byte(cache1Header), ldCacheFile[:len(cache1Header)]) {
                cache1 := ldCache1{}
                if uint32(len(ldCacheFile)) <= ldCache1Size {
                        return nil, errors.New("ldCache format error")
                }
-               err := readFromBytes(&cache1, ldCacheFile[:ldCache1Size])
+               err := reinterpretBytes(&cache1, ldCacheFile[:ldCache1Size])
                if err != nil {
                        return nil, errors.New("ldCache format error")
                }
-               cache1Len := ldCache1Size + cache1.EntryCount*ldCache1EntrySize
+               // Use uint64 arithmetic to avoid overflow when computing the
+               // cache1 section length from the untrusted EntryCount field.
+               cache1Len := uint64(ldCache1Size) + 
uint64(cache1.EntryCount)*uint64(ldCache1EntrySize)
                cache1Len = (cache1Len + 7) / 8 * 8
-               if ldCacheFileSize > (cache1Len + ldCache2Size) {
-                       ldEntries = readCacheFormat2(ldCacheFile)
+               if uint64(ldCacheFileSize) > (cache1Len + uint64(ldCache2Size)) 
{
+                       filteredLibraries = readCacheFormat2(ldCacheFile, 
libraryPrefix)
                } else {
-                       ldEntries = readCacheFormat1(ldCacheFile)
+                       filteredLibraries = readCacheFormat1(ldCacheFile, 
libraryPrefix)
                }
        } else {
-               ldEntries = readCacheFormat2(ldCacheFile)
+               filteredLibraries = readCacheFormat2(ldCacheFile, libraryPrefix)
        }
 
-       if ldEntries == nil {
+       if filteredLibraries == nil {
                return nil, errors.New("ldCache format error")
        }
 
-       // filter library entries with given library name
-       for _, entry := range ldEntries {
-               if strings.HasPrefix(entry.Key, libraryName+".so") {
-                       filteredLibraries = append(filteredLibraries, 
entry.Value)
-               }
-       }
-
        return filteredLibraries, nil
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inspektor-gadget-0.53.0/pkg/uprobetracer/usdt.go 
new/inspektor-gadget-0.53.1/pkg/uprobetracer/usdt.go
--- old/inspektor-gadget-0.53.0/pkg/uprobetracer/usdt.go        2026-06-01 
15:47:32.000000000 +0200
+++ new/inspektor-gadget-0.53.1/pkg/uprobetracer/usdt.go        2026-06-02 
14:33:32.000000000 +0200
@@ -22,6 +22,8 @@
        "io"
        "os"
        "strings"
+
+       "github.com/inspektor-gadget/inspektor-gadget/pkg/utils/safeelf"
 )
 
 // For details regarding the data format of USDT notes, please refer to:
@@ -29,6 +31,12 @@
 const (
        sdtNoteSectionName = ".note.stapsdt"
        sdtBaseSectionName = ".stapsdt.base"
+
+       // maxNoteFieldSize limits the size of individual note name/desc fields 
to
+       // prevent excessive memory allocation from malformed ELF files. There 
is no
+       // standard upper bound for ELF note fields; 1 MiB is a generous 
arbitrary
+       // cap — legitimate USDT notes are typically under 1 KB.
+       maxNoteFieldSize = 1024 * 1024
 )
 
 type noteHeader struct {
@@ -77,7 +85,7 @@
                return nil, fmt.Errorf("ELF file %q is not regular", filepath)
        }
 
-       elfReader, err := elf.NewFile(file)
+       elfReader, err := safeelf.NewFile(file)
        if err != nil {
                return nil, fmt.Errorf("reading elf file %q: %w", filepath, err)
        }
@@ -105,6 +113,9 @@
                wordSize = 8
        }
 
+       // Minimum desc size for a stapsdt note: 3 address fields.
+       minDescSize := 3 * wordSize
+
        // walk through USDT notes, and match with providerName and probeName
        // For details of the structure of ELF notes, please refer to
        // https://man7.org/linux/man-pages/man5/elf.5.html, the `Notes (Nhdr)` 
section
@@ -118,13 +129,23 @@
                        return nil, fmt.Errorf("reading USDT note header: %w", 
err)
                }
 
-               name := make([]byte, alignUp(uint64(header.NameSize), 4))
+               alignedNameSize := alignUp(uint64(header.NameSize), 4)
+               alignedDescSize := alignUp(uint64(header.DescSize), 4)
+
+               if alignedNameSize > maxNoteFieldSize {
+                       return nil, fmt.Errorf("USDT note name too large: %d 
bytes", alignedNameSize)
+               }
+               if alignedDescSize > maxNoteFieldSize {
+                       return nil, fmt.Errorf("USDT note desc too large: %d 
bytes", alignedDescSize)
+               }
+
+               name := make([]byte, alignedNameSize)
                err = binary.Read(notesReader, elfReader.ByteOrder, &name)
                if err != nil {
                        return nil, fmt.Errorf("reading USDT note name: %w", 
err)
                }
 
-               desc := make([]byte, alignUp(uint64(header.DescSize), 4))
+               desc := make([]byte, alignedDescSize)
                err = binary.Read(notesReader, elfReader.ByteOrder, &desc)
                if err != nil {
                        return nil, fmt.Errorf("reading USDT note desc: %w", 
err)
@@ -134,18 +155,22 @@
                        continue
                }
 
+               if len(desc) < minDescSize {
+                       return nil, fmt.Errorf("malformed stapsdt note: desc 
too short (%d bytes, need %d)", len(desc), minDescSize)
+               }
+
                elfLocation := elfReader.ByteOrder.Uint64(desc[:wordSize])
                elfBase := elfReader.ByteOrder.Uint64(desc[wordSize : 
2*wordSize])
                elfSemaphore := elfReader.ByteOrder.Uint64(desc[2*wordSize : 
3*wordSize])
 
                diff := baseSection.Addr - elfBase
-               location, err := vaddr2ElfOffset(elfReader, elfLocation+diff)
+               location, err := vaddr2ElfOffset(elfReader.File, 
elfLocation+diff)
                if err != nil {
                        return nil, err
                }
 
                if elfSemaphore != 0 {
-                       elfSemaphore, err = vaddr2ElfOffset(elfReader, 
elfSemaphore+diff)
+                       elfSemaphore, err = vaddr2ElfOffset(elfReader.File, 
elfSemaphore+diff)
                        if err != nil {
                                return nil, err
                        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inspektor-gadget-0.53.0/pkg/utils/safeelf/safeelf.go 
new/inspektor-gadget-0.53.1/pkg/utils/safeelf/safeelf.go
--- old/inspektor-gadget-0.53.0/pkg/utils/safeelf/safeelf.go    1970-01-01 
01:00:00.000000000 +0100
+++ new/inspektor-gadget-0.53.1/pkg/utils/safeelf/safeelf.go    2026-06-02 
14:33:32.000000000 +0200
@@ -0,0 +1,78 @@
+// Copyright 2026 The Inspektor Gadget authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package safeelf provides panic-safe wrappers around debug/elf.
+//
+// Go's debug/elf is not hardened against adversarial inputs and may panic on
+// malformed data. Since Inspektor Gadget parses ELF files from untrusted
+// containers in a privileged process, we wrap all operations in recover() to
+// turn panics into errors.
+//
+// This approach is inspired by cilium/ebpf's internal SafeELFFile:
+// https://github.com/cilium/ebpf/blob/main/internal/elf.go
+package safeelf
+
+import (
+       "debug/elf"
+       "fmt"
+       "io"
+)
+
+// File wraps an *elf.File with panic recovery on operations that may crash
+// on malformed input.
+type File struct {
+       *elf.File
+}
+
+// NewFile reads an ELF file safely. Any panic during parsing is turned into
+// an error.
+func NewFile(r io.ReaderAt) (safe *File, err error) {
+       defer func() {
+               if r := recover(); r != nil {
+                       safe = nil
+                       err = fmt.Errorf("panic reading ELF file: %v", r)
+               }
+       }()
+
+       f, err := elf.NewFile(r)
+       if err != nil {
+               return nil, err
+       }
+
+       return &File{f}, nil
+}
+
+// Symbols is the safe version of elf.File.Symbols.
+func (f *File) Symbols() (syms []elf.Symbol, err error) {
+       defer func() {
+               if r := recover(); r != nil {
+                       syms = nil
+                       err = fmt.Errorf("panic reading ELF symbols: %v", r)
+               }
+       }()
+
+       return f.File.Symbols()
+}
+
+// DynamicSymbols is the safe version of elf.File.DynamicSymbols.
+func (f *File) DynamicSymbols() (syms []elf.Symbol, err error) {
+       defer func() {
+               if r := recover(); r != nil {
+                       syms = nil
+                       err = fmt.Errorf("panic reading ELF dynamic symbols: 
%v", r)
+               }
+       }()
+
+       return f.File.DynamicSymbols()
+}

++++++ inspektor-gadget.obsinfo ++++++
--- /var/tmp/diff_new_pack.GQjYo1/_old  2026-06-05 15:03:50.037080736 +0200
+++ /var/tmp/diff_new_pack.GQjYo1/_new  2026-06-05 15:03:50.041080902 +0200
@@ -1,5 +1,5 @@
 name: inspektor-gadget
-version: 0.53.0
-mtime: 1780321652
-commit: 40398a64e15b96366215dbd05e0a52b969a4a0c1
+version: 0.53.1
+mtime: 1780403612
+commit: ec69da2e00c39bc43f389f943899e5ff9c7b011a
 

++++++ vendor.tar.gz ++++++
/work/SRC/openSUSE:Factory/inspektor-gadget/vendor.tar.gz 
/work/SRC/openSUSE:Factory/.inspektor-gadget.new.2375/vendor.tar.gz differ: 
char 129, line 2

Reply via email to