Skip to content

Commit 3cfde93

Browse files
committed
Fix ksym buffer overflow on i386
Commit 78074c5 ("info: expose more prog jited info"), which made its way into v0.17.0, resulted in random runc CI failures on i386 (see [1]). In some cases it manifested in a panic or SIGSEGV, and in others we saw a slightly broken JSON, in which the first 4 bytes of a key were replaced with 0xff byte. Changing uintptr (which is 32 bit) back to uint64 fixes the issue for runc. It changes the public API but I see no way around it (and the uintptr cast of uint64 which was there before does not look correct either). Alas, I don't have a good reproducer, nor a unit test. For a rather complicated one, see [1]. [1]: opencontainers/runc#4594 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 9f20115 commit 3cfde93

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

info.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ type programJitedInfo struct {
185185
// subprograms.
186186
//
187187
// Available from 4.18.
188-
ksyms []uintptr
188+
ksyms []uint64
189189
numKsyms uint32
190190

191191
// insns holds the JITed machine native instructions of the program,
@@ -344,7 +344,7 @@ func newProgramInfoFromFd(fd *sys.FD) (*ProgramInfo, error) {
344344

345345
if info.NrJitedKsyms > 0 {
346346
pi.jitedInfo.numKsyms = info.NrJitedKsyms
347-
pi.jitedInfo.ksyms = make([]uintptr, info.NrJitedKsyms)
347+
pi.jitedInfo.ksyms = make([]uint64, info.NrJitedKsyms)
348348
info2.JitedKsyms = sys.NewSlicePointer(pi.jitedInfo.ksyms)
349349
info2.NrJitedKsyms = info.NrJitedKsyms
350350
makeSecondCall = true
@@ -630,7 +630,7 @@ func (pi *ProgramInfo) VerifiedInstructions() (uint32, bool) {
630630
// programs without subprograms (bpf2bpf calls).
631631
//
632632
// The bool return value indicates whether this optional field is available.
633-
func (pi *ProgramInfo) JitedKsymAddrs() ([]uintptr, bool) {
633+
func (pi *ProgramInfo) JitedKsymAddrs() ([]uint64, bool) {
634634
return pi.jitedInfo.ksyms, len(pi.jitedInfo.ksyms) > 0
635635
}
636636

0 commit comments

Comments
 (0)