Comment 2 for bug 2028932

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

I just finished bisect between -1007 and -1008

ca6f352ba5c8ccde01289d433401f28e6c260e07 is the first bad commit
commit ca6f352ba5c8ccde01289d433401f28e6c260e07
Author: Andrii Nakryiko <email address hidden>
Date: Mon May 8 23:55:02 2023 -0700

    libbpf: fix offsetof() and container_of() to work with CO-RE

    BugLink: https://bugs.launchpad.net/bugs/2028528

    [ Upstream commit bdeeed3498c7871c17465bb4f11d1bc67f9098af ]

    It seems like __builtin_offset() doesn't preserve CO-RE field
    relocations properly. So if offsetof() macro is defined through
    __builtin_offset(), CO-RE-enabled BPF code using container_of() will be
    subtly and silently broken.

    To avoid this problem, redefine offsetof() and container_of() in the
    form that works with CO-RE relocations more reliably.

    Fixes: 5fbc220862fc ("tools/libpf: Add offsetof/container_of macro in bpf_helpers.h")
    Reported-by: Lennart Poettering <email address hidden>
    Signed-off-by: Andrii Nakryiko <email address hidden>
    Acked-by: Yonghong Song <email address hidden>
    Link: https://<email address hidden>
    Signed-off-by: Alexei Starovoitov <email address hidden>
    Signed-off-by: Sasha Levin <email address hidden>
    Signed-off-by: Timo Aaltonen <email address hidden>

 tools/lib/bpf/bpf_helpers.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)