Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute and test CO-RE relocations of bpf2bpf subprogs #590

Merged
merged 2 commits into from Mar 7, 2022

Commits on Mar 7, 2022

  1. btf: include CO-RE relocations of bpf2bpf subprograms

    ProgramSpecs read from an ELF contain the full instruction streams from the
    bpf2bpf subprograms they call. When marshaling a program to be inserted into
    the kernel, FuncInfos and LineInfos are collected from all called subprogs,
    but CO-RE relocations were notably skipped after the linker rework in 9d739bd.
    
    This commit gathers CO-RE relos for all subprogs included in the final
    instruction stream and modifies their offsets to point to their new locations.
    
    Signed-off-by: Timo Beckers <timo@isovalent.com>
    ti-mo committed Mar 7, 2022
    Copy the full SHA
    30dc747 View commit details
    Browse the repository at this point in the history
  2. btf: add CO-RE read test that fails unless relocations were correctly…

    … applied
    
    The linker rework in 9d739bd caused a piece of code that appended CORERelos
    to the entrypoint instruction stream to be forgotten. The existing CO-RE tests
    were all written in a way where the BPF programs would return 0 (success) if
    no CO-RE relocations were applied at all.
    
    This caused CO-RE relocations against functions (subprogs) that were only
    included by a bpf2bpf call to be skipped.
    
    This patch adds a broken test program that returns non-zero if left unaltered,
    and requires CO-RE relocation against another BTF blob to return 0.
    Additionally, the checks are performed from a non-inlined subprogram to ensure
    CO-RE relocations against subprogs work.
    
    Signed-off-by: Timo Beckers <timo@isovalent.com>
    ti-mo committed Mar 7, 2022
    Copy the full SHA
    e701675 View commit details
    Browse the repository at this point in the history