mbox series

[bpf-next,v5,0/2] bpf: Reject attaching fexit/fmod_ret to __noreturn functions

Message ID 20250318114447.75484-1-laoar.shao@gmail.com (mailing list archive)
Headers show
Series bpf: Reject attaching fexit/fmod_ret to __noreturn functions | expand

Message

Yafang Shao March 18, 2025, 11:44 a.m. UTC
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.

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

v4->v5:
- Remove unnecessary functions (Alexei)
- Use BTF_ID directly (Alexei)

v3->v4: https://lore.kernel.org/bpf/20250317121735.86515-1-laoar.shao@gmail.com/
- Reject also fmod_ret (Alexei)
- Fix build warnings and remove unnecessary functions (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/fmod_ret to __noreturn functions
  selftests/bpf: Add selftest for attaching fexit to __noreturn
    functions

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

Comments

patchwork-bot+netdevbpf@kernel.org March 19, 2025, 2:20 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 18 Mar 2025 19:44:45 +0800 you wrote:
> 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.
> 
> Once a more robust solution is implemented, this workaround can be removed.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v5,1/2] bpf: Reject attaching fexit/fmod_ret to __noreturn functions
    https://git.kernel.org/bpf/bpf-next/c/cfe816d469dc
  - [bpf-next,v5,2/2] selftests/bpf: Add selftest for attaching fexit to __noreturn functions
    https://git.kernel.org/bpf/bpf-next/c/be16ddeaae96

You are awesome, thank you!