BPF List
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org, jpoimboe@kernel.org, peterz@infradead.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH v2 bpf-next 0/3] bpf: Reject attaching fexit to __noreturn functions
Date: Sun, 23 Feb 2025 14:27:32 +0800	[thread overview]
Message-ID: <20250223062735.3341-1-laoar.shao@gmail.com> (raw)

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.

v1->v2:
- 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 (3):
  objtool: Copy noreturns.h to include/linux
  bpf: Reject attaching fexit to functions annotated with __noreturn
  selftests/bpf: Add selftest for attaching fexit to __noreturn
    functions

 include/linux/noreturns.h                     | 52 +++++++++++++++++++
 kernel/bpf/verifier.c                         | 11 ++++
 tools/objtool/Documentation/objtool.txt       |  3 +-
 tools/objtool/sync-check.sh                   |  2 +
 .../bpf/prog_tests/fexit_noreturns.c          |  9 ++++
 .../selftests/bpf/progs/fexit_noreturns.c     | 15 ++++++
 6 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/noreturns.h
 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


             reply	other threads:[~2025-02-23  6:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-23  6:27 Yafang Shao [this message]
2025-02-23  6:27 ` [PATCH v2 bpf-next 1/3] objtool: Copy noreturns.h to include/linux Yafang Shao
2025-02-23  8:21   ` kernel test robot
2025-02-23 20:12   ` Alexei Starovoitov
2025-02-24  2:00     ` Yafang Shao
2025-02-23  6:27 ` [PATCH v2 bpf-next 2/3] bpf: Reject attaching fexit to functions annotated with __noreturn Yafang Shao
2025-02-23  6:27 ` [PATCH v2 bpf-next 3/3] selftests/bpf: Add selftest for attaching fexit to __noreturn functions Yafang Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250223062735.3341-1-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=peterz@infradead.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox