BPF List
 help / color / mirror / Atom feed
* [PATCH v3 bpf-next 0/3] bpf: Reject attaching fexit to __noreturn functions
@ 2025-02-24 11:46 Yafang Shao
  2025-02-24 11:46 ` [PATCH v3 1/2] bpf: Reject attaching fexit to functions annotated with __noreturn Yafang Shao
  2025-02-24 11:46 ` [PATCH v3 2/2] selftests/bpf: Add selftest for attaching fexit to __noreturn functions Yafang Shao
  0 siblings, 2 replies; 9+ messages in thread
From: Yafang Shao @ 2025-02-24 11:46 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, jpoimboe, peterz
  Cc: bpf, Yafang Shao

Attaching fexit probes to functions marked with __noreturn may lead to
unpredictable behavior. To avoid this, we will reject attaching probes to
such functions. Currently, there is no ideal solution, so we will hardcode
a check for all __noreturn functions. Since objtool already handles
this, we will leverage its implementation.

Once a more robust solution is found, this workaround can be removed.

v2->v3:
- Remove the need for objtool (Alexei)

v1->v2: https://lore.kernel.org/bpf/20250223062735.3341-1-laoar.shao@gmail.com/
- keep tools/objtool/noreturns.h as is (Josh)
- Add noreturns.h to objtool/sync-check.sh (Josh)
- Add verbose for the reject and simplify the test case (Song)

v1: https://lore.kernel.org/bpf/20250211023359.1570-1-laoar.shao@gmail.com/

Yafang Shao (2):
  bpf: Reject attaching fexit to functions annotated with __noreturn
  selftests/bpf: Add selftest for attaching fexit to __noreturn
    functions

 kernel/bpf/verifier.c                         | 57 +++++++++++++++++++
 .../bpf/prog_tests/fexit_noreturns.c          |  9 +++
 .../selftests/bpf/progs/fexit_noreturns.c     | 15 +++++
 3 files changed, 81 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/fexit_noreturns.c
 create mode 100644 tools/testing/selftests/bpf/progs/fexit_noreturns.c

-- 
2.43.5


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

end of thread, other threads:[~2025-02-26  3:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 11:46 [PATCH v3 bpf-next 0/3] bpf: Reject attaching fexit to __noreturn functions Yafang Shao
2025-02-24 11:46 ` [PATCH v3 1/2] bpf: Reject attaching fexit to functions annotated with __noreturn Yafang Shao
2025-02-24 17:30   ` Alexei Starovoitov
2025-02-25  7:34     ` Yafang Shao
2025-02-25 18:39       ` Alexei Starovoitov
2025-02-26  3:55         ` Yafang Shao
2025-02-25 17:52   ` Josh Poimboeuf
2025-02-26  3:54     ` Yafang Shao
2025-02-24 11:46 ` [PATCH v3 2/2] selftests/bpf: Add selftest for attaching fexit to __noreturn functions Yafang Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox