lkml.org 
[lkml]   [2022]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v4 42/45] bpf: kmsan: initialize BPF registers with zeroes
    From
    When executing BPF programs, certain registers may get passed
    uninitialized to helper functions. E.g. when performing a JMP_CALL,
    registers BPF_R1-BPF_R5 are always passed to the helper, no matter how
    many of them are actually used.

    Passing uninitialized values as function parameters is technically
    undefined behavior, so we work around it by always initializing the
    registers.

    Signed-off-by: Alexander Potapenko <glider@google.com>
    ---
    Link: https://linux-review.googlesource.com/id/I40f39d26232b14816c14ba64a0ea4a8f336f2675
    ---
    kernel/bpf/core.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
    index 5f6f3f829b368..0ba7dd90a2ab3 100644
    --- a/kernel/bpf/core.c
    +++ b/kernel/bpf/core.c
    @@ -2039,7 +2039,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn)
    static unsigned int PROG_NAME(stack_size)(const void *ctx, const struct bpf_insn *insn) \
    { \
    u64 stack[stack_size / sizeof(u64)]; \
    - u64 regs[MAX_BPF_EXT_REG]; \
    + u64 regs[MAX_BPF_EXT_REG] = {}; \
    \
    FP = (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; \
    ARG1 = (u64) (unsigned long) ctx; \
    --
    2.37.0.rc0.161.g10f37bed90-goog
    \
     
     \ /
      Last update: 2022-07-01 16:31    [W:4.250 / U:0.128 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site