mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
Add the first Landlock tracepoints, for ruleset lifecycle: landlock_create_ruleset fires from the landlock_create_ruleset() syscall handler, and landlock_free_ruleset fires in free_ruleset() before the ruleset is freed. These tracepoints, and the ones added by the following commits, share a common design. Rather than one polymorphic event distinguished by a status field (as audit uses a shared record type with a "status=" field), each lifecycle transition and denial type gets its own event with a type-safe TP_PROTO, giving precise ftrace filtering by event name and type-safe eBPF access. TP_PROTO passes the object pointer and the fields are read from it in TP_fast_assign, so an eBPF program reads the full object state (rules, access masks, hierarchy) via BTF from a single pointer rather than from the flattened TP_STRUCT__entry fields. The whole cost is paid only when a tracer is attached; the static branch is not taken otherwise. Trace fields carry the bare access-right and scope names (read_file), reusing the audit name tables; audit prepends the category (fs.read_file), which the trace event name already conveys. The trace header's DOC comment documents the consistency and locking guarantees these events share. create_ruleset needs no lock because the ruleset is not yet shared (its file descriptor is not yet installed). The deallocation events use the "free_" prefix, not "drop_", because they fire when the object is actually freed. Add trace.c, built for CONFIG_TRACEPOINTS, which defines CREATE_TRACE_POINTS, and extend CONFIG_SECURITY_LANDLOCK_LOG to also be selected by CONFIG_TRACEPOINTS so the common log framework is available to a tracepoints-only build. Add an id field to struct landlock_ruleset, gated on CONFIG_TRACEPOINTS and assigned from landlock_get_id_range() at creation. Only the tracepoints consume it (audit identifies domains, not rulesets), so it does not exist in an audit-only build. The Landlock ID is a stable u64 that names the ruleset across the trace stream and uses the same scheme as audit, so a ruleset can be correlated between trace and audit records. Cc: Günther Noack <gnoack@google.com> Cc: Justin Suess <utilityemal77@gmail.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tingmao Wang <m@maowtm.org> Link: https://patch.msgid.link/20260811094338.288094-8-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
config SECURITY_LANDLOCK
|
|
bool "Landlock support"
|
|
depends on SECURITY
|
|
select SECURITY_NETWORK
|
|
select SECURITY_PATH
|
|
help
|
|
Landlock is a sandboxing mechanism that enables processes to restrict
|
|
themselves (and their future children) by gradually enforcing
|
|
tailored access control policies. A Landlock security policy is a
|
|
set of access rights (e.g. open a file in read-only, make a
|
|
directory, etc.) tied to a file hierarchy. Such policy can be
|
|
configured and enforced by any processes for themselves using the
|
|
dedicated system calls: landlock_create_ruleset(),
|
|
landlock_add_rule(), and landlock_restrict_self().
|
|
|
|
See Documentation/userspace-api/landlock.rst for further information.
|
|
|
|
If you are unsure how to answer this question, answer N. Otherwise,
|
|
you should also prepend "landlock," to the content of CONFIG_LSM to
|
|
enable Landlock at boot time.
|
|
|
|
config SECURITY_LANDLOCK_LOG
|
|
bool
|
|
depends on SECURITY_LANDLOCK
|
|
default y if AUDIT || TRACEPOINTS
|
|
|
|
config SECURITY_LANDLOCK_KUNIT_TEST
|
|
bool "KUnit tests for Landlock" if !KUNIT_ALL_TESTS
|
|
depends on KUNIT=y
|
|
depends on SECURITY_LANDLOCK
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
Build KUnit tests for Landlock.
|
|
|
|
See the KUnit documentation in Documentation/dev-tools/kunit
|
|
|
|
Run all KUnit tests for Landlock with:
|
|
./tools/testing/kunit/kunit.py run --kunitconfig security/landlock
|
|
|
|
If you are unsure how to answer this question, answer N.
|