Skip to content

Commit f5dd51a

Browse files
etsalKernel Patches Daemon
authored andcommitted
libbpf: turn relo_core->sym_off unsigned
The symbols' relocation offsets in BPF are stored in an int field, but cannot actually be negative. When in the next patch libbpf relocates globals to the end of the arena, it is also possible to have valid offsets > 2GiB that are used to calculate the final relo offsets. Avoid accidentally interpreting large offsets as negative by turning the sym_off field unsigned. Signed-off-by: Emil Tsalapatis <[email protected]> Acked-by: Eduard Zingerman <[email protected]>
1 parent 52eecfb commit f5dd51a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ struct reloc_desc {
380380
const struct bpf_core_relo *core_relo; /* used when type == RELO_CORE */
381381
struct {
382382
int map_idx;
383-
int sym_off;
383+
unsigned int sym_off;
384384
/*
385385
* The following two fields can be unionized, as the
386386
* ext_idx field is used for extern symbols, and the
@@ -763,7 +763,7 @@ struct bpf_object {
763763

764764
struct {
765765
struct bpf_program *prog;
766-
int sym_off;
766+
unsigned int sym_off;
767767
int fd;
768768
} *jumptable_maps;
769769
size_t jumptable_map_cnt;

0 commit comments

Comments
 (0)