All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v5 0/3] bpf: Fix tailcall infinite loop caused by freplace
@ 2024-10-06 13:01 Leon Hwang
  2024-10-06 13:01 ` [PATCH bpf-next v5 1/3] bpf: Prevent " Leon Hwang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Leon Hwang @ 2024-10-06 13:01 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, toke, martin.lau, yonghong.song, puranjay,
	xukuohai, eddyz87, iii, leon.hwang, kernel-patches-bot

Previously, I fixed a tailcall infinite loop issue caused by trampoline[0].

At this time, I fix a tailcall infinite loop issue caused by tailcall and
freplace combination by preventing updating extended prog to prog_array map
and preventing extending tail callee prog with freplace:

1. If a prog or its subprog has been extended by freplace prog, the prog
   can not be updated to prog_array map.
2. If a prog has been updated to prog_array map, it or its subprog can not
   be extended by freplace prog.

v4 -> v5:
  * Move code of linking/unlinking target prog of freplace to trampoline.c.
  * Address comments from Alexei:
    * Change type of prog_array_member_cnt to u64.
    * Combine two patches to one.

v3 -> v4:
  * Address comments from Eduard:
    * Rename 'tail_callee_cnt' to 'prog_array_member_cnt'.
    * Add comment to 'prog_array_member_cnt'.
    * Use a mutex to protect 'is_extended' and 'prog_array_member_cnt'.

v2 -> v3:
  * Address comments from Alexei:
    * Stop hacking JIT.
    * Prevent the specific use case at attach/update time.

v1 -> v2:
  * Address comment from Eduard:
    * Explain why nop5 and xor/nop3 are swapped at prologue.
  * Address comment from Alexei:
    * Disallow attaching tail_call_reachable freplace prog to
      not-tail_call_reachable target in verifier.
  * Update "bpf, arm64: Fix tailcall infinite loop caused by freplace" with
    latest arm64 JIT code.

Links:
[0] https://lore.kernel.org/bpf/20230912150442.2009-1-hffilwlqm@gmail.com/

Leon Hwang (3):
  bpf: Prevent tailcall infinite loop caused by freplace
  selftests/bpf: Add a test case to confirm a tailcall infinite loop
    issue has been prevented
  selftests/bpf: Add cases to test tailcall in freplace

 include/linux/bpf.h                           |  21 ++
 kernel/bpf/arraymap.c                         |  23 +-
 kernel/bpf/core.c                             |   1 +
 kernel/bpf/syscall.c                          |  21 +-
 kernel/bpf/trampoline.c                       |  43 ++++
 .../selftests/bpf/prog_tests/tailcalls.c      | 196 +++++++++++++++++-
 .../tailcall_bpf2bpf_hierarchy_freplace.c     |  30 +++
 .../testing/selftests/bpf/progs/tc_bpf2bpf.c  |  37 +++-
 8 files changed, 361 insertions(+), 11 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy_freplace.c

-- 
2.44.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-08  1:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06 13:01 [PATCH bpf-next v5 0/3] bpf: Fix tailcall infinite loop caused by freplace Leon Hwang
2024-10-06 13:01 ` [PATCH bpf-next v5 1/3] bpf: Prevent " Leon Hwang
2024-10-07 20:32   ` kernel test robot
2024-10-08  1:40     ` Leon Hwang
2024-10-07 21:33   ` kernel test robot
2024-10-07 22:04   ` kernel test robot
2024-10-06 13:01 ` [PATCH bpf-next v5 2/3] selftests/bpf: Add a test case to confirm a tailcall infinite loop issue has been prevented Leon Hwang
2024-10-06 13:01 ` [PATCH bpf-next v5 3/3] selftests/bpf: Add cases to test tailcall in freplace Leon Hwang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.