android_kernel_sony_sdm845/kernel/trace
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Andrey Ignatov b9e0d4095d BACKPORT: bpf: Check attach type at prog load time
== The problem ==

There are use-cases when a program of some type can be attached to
multiple attach points and those attach points must have different
permissions to access context or to call helpers.

E.g. context structure may have fields for both IPv4 and IPv6 but it
doesn't make sense to read from / write to IPv6 field when attach point
is somewhere in IPv4 stack.

Same applies to BPF-helpers: it may make sense to call some helper from
some attach point, but not from other for same prog type.

== The solution ==

Introduce `expected_attach_type` field in in `struct bpf_attr` for
`BPF_PROG_LOAD` command. If scenario described in "The problem" section
is the case for some prog type, the field will be checked twice:

1) At load time prog type is checked to see if attach type for it must
   be known to validate program permissions correctly. Prog will be
   rejected with EINVAL if it's the case and `expected_attach_type` is
   not specified or has invalid value.

2) At attach time `attach_type` is compared with `expected_attach_type`,
   if prog type requires to have one, and, if they differ, attach will
   be rejected with EINVAL.

The `expected_attach_type` is now available as part of `struct bpf_prog`
in both `bpf_verifier_ops->is_valid_access()` and
`bpf_verifier_ops->get_func_proto()` () and can be used to check context
accesses and calls to helpers correspondingly.

Initially the idea was discussed by Alexei Starovoitov <ast@fb.com> and
Daniel Borkmann <daniel@iogearbox.net> here:
https://marc.info/?l=linux-netdev&m=152107378717201&w=2

Change-Id: Iea40e7ab753ac77256b64a464944e73daacee5db
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
2026-05-15 17:56:14 +07:00
..
blktrace.c blktrace: Fix output non-blktrace event when blk_classic option enabled 2023-01-07 12:07:20 +01:00
bpf_trace.c BACKPORT: bpf: Check attach type at prog load time 2026-05-15 17:56:14 +07:00
ftrace.c This is the 4.9.334 stable release 2022-11-28 15:45:23 +00:00
gpu-traces.c
ipc_logging.c
ipc_logging_debug.c
ipc_logging_private.h
Kconfig BACKPORT: bpf: add a bpf_override_function helper 2026-05-15 17:55:59 +07:00
Makefile
msm_rtb.c
power-traces.c
ring_buffer.c ring_buffer: Do not deactivate non-existant pages 2022-11-25 17:35:40 +01:00
ring_buffer_benchmark.c
rpm-traces.c
trace.c Merge branch 'android-4.9-q' of https://android.googlesource.com/kernel/common into lineage-20 2023-01-19 15:42:12 +01:00
trace.h Merge remote-tracking branch 'common/android-4.9-q' into lineage-18.1-caf-sdm845 2021-12-27 02:07:39 +02:00
trace_benchmark.c
trace_benchmark.h
trace_branch.c
trace_clock.c tracing: Do no increment trace_clock_global() by one 2021-06-30 08:49:17 -04:00
trace_cpu_freq_switch.c
trace_entries.h tracing: Set kernel_stack's caller size properly 2020-10-01 20:40:05 +02:00
trace_event_perf.c
trace_events.c Merge remote-tracking branch 'common/android-4.9-q' into lineage-18.1-caf-sdm845 2021-12-27 02:07:39 +02:00
trace_events_filter.c
trace_events_filter_test.h
trace_events_hist.c tracing: Do not reference char * as a string in histograms 2021-07-20 16:21:11 +02:00
trace_events_trigger.c tracing: Fix event trigger to accept redundant spaces 2020-06-30 15:38:45 -04:00
trace_export.c
trace_functions.c tracing: Have all levels of checks prevent recursion 2021-10-27 09:34:01 +02:00
trace_functions_graph.c
trace_hwlat.c tracing/hwlat: Honor the tracing_cpumask 2020-08-26 10:29:03 +02:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c BACKPORT: bpf: add a bpf_override_function helper 2026-05-15 17:55:59 +07:00
trace_mmiotrace.c
trace_nop.c
trace_output.c UPSTREAM: trace: add variant without spacing in trace_print_hex_seq 2026-05-15 17:54:49 +07:00
trace_output.h
trace_printk.c
trace_probe.c
trace_probe.h BACKPORT: bpf: add a bpf_override_function helper 2026-05-15 17:55:59 +07:00
trace_sched_switch.c
trace_sched_wakeup.c kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail 2020-01-14 20:04:26 +01:00
trace_selftest.c ftrace: Handle tracing when switching between context 2020-11-10 10:24:02 +01:00
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined 2020-01-14 20:04:26 +01:00
trace_stat.c tracing: Fix very unlikely race of registering two stat tracers 2020-02-28 15:42:21 +01:00
trace_stat.h
trace_syscalls.c UPSTREAM: perf/bpf: fix a clang compilation issue 2026-05-15 17:55:22 +07:00
trace_uprobe.c Merge remote-tracking branch 'common/android-4.9-q' into android12-4.9-sdm845 2022-03-31 22:52:51 +03:00
tracing_map.c tracing: Fix a kmemleak false positive in tracing_map 2021-12-22 09:05:13 +01:00
tracing_map.h