Skip to content

call -1 instructions no longer load without error #1797

Open
@brycekahle

Description

@brycekahle

Describe the bug

f086705 breaks loading of programs with error:
decoding instructions for section <sectionname>: offset <offset>: invalid constant 0xffffffff

The actual instruction looks like 85 00 00 00 ff ff ff ff call -1

This is happening because we have call -1 instructions that we use as sentinels for patching before loading into the kernel. Since 0xffff is a valid 32 bit value, it shouldn't be considered an invalid constant or instruction. I'm not sure why it is being sign-extended to 64 bits in the error message.

How to reproduce

Write an ebpf program with the following:

#define PATCH_TARGET -1
static void *(*bpf_patch)(unsigned long, ...) = (void *)PATCH_TARGET;

and in your program use it

bpf_patch(0, 0);

then try to load the program using cilium/ebpf

Version information

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions