Skip to contentSkip to conversation

Patch "bpf: Fix off-by-one in tail call count limiting" has been added to the 5.14-stable tree

DISCUSSION Daniel Borkmann 1 participant 1 message Sep 16, 2021 1 message not in the archive BPF

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Daniel Borkmann

author maintainer
#1 lore raw

Hi Sasha,

Quoted 14 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

bpf: Fix off-by-one in tail call count limiting

to the 5.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
bpf-fix-off-by-one-in-tail-call-count-limiting.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 7 lines

commit 0af0fa0371eb376731a350bfdd8687e7ec206bb9

Author: Johan Almbladh <[email protected]>
Date:   Wed Jul 28 18:47:41 2021 +0200

bpf: Fix off-by-one in tail call count limiting

[ Upstream commit b61a28cf11d61f512172e673b8f8c4a6c789b425 ]

Please either drop this commit from stable queues, or also queue its revert as well (in case you don't have a filter in place, and there's a chance this could get re-queued again in future by accident):

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f9dabe016b63c9629e152bf876c126c29de223cb

Quoted 16 lines

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.

kernel/bpf/core.c +0 -0
index 0a28a8095d3e..82af6279992d 100644

kernel/bpf/core.c static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn) · line 1570

Quoted 8 lines
kernel/bpf/core.c +1 -1
@@ -1564,7 +1564,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn)
 
  		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++;

Thanks,
Daniel