lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260123084248.259278-1-changwoo@igalia.com>
Date: Fri, 23 Jan 2026 17:42:46 +0900
From: Changwoo Min <changwoo@...lia.com>
To: Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>
Cc: Martin KaFai Lau <martin.lau@...ux.dev>,
	Eduard Zingerman <eddyz87@...il.com>,
	Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Shuah Khan <shuah@...nel.org>,
	kernel-dev@...lia.com,
	bpf@...r.kernel.org,
	sched-ext@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	Changwoo Min <changwoo@...lia.com>
Subject: [PATCH bpf-next v1 0/2] bpf: Introduce execution context detection kfuncs

This series introduces four new kfuncs -- bpf_in_nmi(), bpf_in_hardirq(), 
bpf_in_serving_softirq(), and bpf_in_task() -- to allow BPF programs to 
query the current execution context.

While BPF programs can often infer their context from attachment points, 
subsystems like sched_ext may call the same BPF logic from multiple 
contexts (e.g., task-to-task wake-ups vs. interrupt-to-task wake-ups). 
These kfuncs provide a reliable way to branch logic based on the 
current CPU execution state.

The series includes a new selftest suite, ctx_kfunc, which uses 
bpf_testmod to verify context detection across Task, HardIRQ, and 
SoftIRQ boundaries via irq_work and tasklets. NMI context testing is 
omitted from the suite as NMIs cannot be triggered deterministically 
within the software-only environments typically used for BPF CI.

Changwoo Min (2):
  bpf: Introduce execution context detection kfuncs
  selftests/bpf: Add tests for execution context kfuncs

 kernel/bpf/helpers.c                          | 44 ++++++++++++++
 .../selftests/bpf/prog_tests/ctx_kfunc.c      | 59 +++++++++++++++++++
 tools/testing/selftests/bpf/progs/test_ctx.c  | 51 ++++++++++++++++
 .../selftests/bpf/test_kmods/bpf_testmod.c    | 32 ++++++++++
 .../bpf/test_kmods/bpf_testmod_kfunc.h        |  4 ++
 5 files changed, 190 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/ctx_kfunc.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_ctx.c

-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ