Re: [PATCH bpf-next] bpf: bpf_core_calc_relo_insn() should verify relocation type id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2024-08-21 at 13:08 -0700, Andrii Nakryiko wrote:

[...]

> Ok, then let's do that. I don't want static analysers complaining
> about this when checking libbpf code base.

Just want to rant a bit.
Here is a footgun in the relo_core.c:

    #ifdef __KERNEL__
    ...
    #undef pr_warn
    #undef pr_info
    #undef pr_debug
    #define pr_warn(fmt, log, ...)      bpf_log((void *)log, fmt, "", ##__VA_ARGS__)
    #define pr_info(fmt, log, ...)      bpf_log((void *)log, fmt, "", ##__VA_ARGS__)
    #define pr_debug(fmt, log, ...)     bpf_log((void *)log, fmt, "", ##__VA_ARGS__)
                          ^^^                   ^^^^^^^^^^^       ^^
                     first format param,        prog_name         replacement for
                     usually prog_name          cast to           first param
                                                verifier log
    ...
    #else
    ...
    #endif

    int bpf_core_calc_relo_insn(const char *prog_name, ...)
    {
        ...
        pr_warn("prog '%s': relo #%d: bad type id %u\n",
                prog_name, relo_idx, local_id);
        ...
    }

And in the verifier.c:

    err = bpf_core_calc_relo_insn((void *)ctx->log, relo, ...);
                                  ^^^^^^^^^^^^^^^^
                                  This is a prog_name parameter

Just spent more than an hour trying to figure out why passing real
program name (char *) does not work.
I'll think on a refactoring, but that is for another series.






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux