lkml.org 
[lkml]   [2021]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 35/74] bpf: Fix off-by-one in tail call count limiting
    Date
    From: Johan Almbladh <johan.almbladh@anyfinetworks.com>

    [ Upstream commit b61a28cf11d61f512172e673b8f8c4a6c789b425 ]

    Before, the interpreter allowed up to MAX_TAIL_CALL_CNT + 1 tail calls.
    Now precisely MAX_TAIL_CALL_CNT is allowed, which is in line with the
    behavior of the x86 JITs.

    Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Acked-by: Yonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/20210728164741.350370-1-johan.almbladh@anyfinetworks.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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 d2b6d2459aad..b4a35c11bc92 100644
    --- a/kernel/bpf/core.c
    +++ b/kernel/bpf/core.c
    @@ -1198,7 +1198,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u64 *stack)

    if (unlikely(index >= array->map.max_entries))
    goto out;
    - if (unlikely(tail_call_cnt > MAX_TAIL_CALL_CNT))
    + if (unlikely(tail_call_cnt >= MAX_TAIL_CALL_CNT))
    goto out;

    tail_call_cnt++;
    --
    2.30.2
    \
     
     \ /
      Last update: 2021-09-09 15:40    [W:4.033 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site