Commit 9623c3c6 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'bpf-add-the-missing-fsession'

Menglong Dong says:

====================
bpf: add the missing fsession

Add the missing fsession attach type to the BPF docs, verifier log and
bpftool.

Changes since v2:
- replace "FENTRY/FEXIT/FSESSION" with "Tracing" in the 1st patch
- v2: https://lore.kernel.org/all/20260408062109.386083-1-dongml2@chinatelecom.cn/

Changes since v1:
- add a missing FSESSION in bpf_check_attach_target() in the 1st patch
- v1: https://lore.kernel.org/all/20260408031416.266229-1-dongml2@chinatelecom.cn/
====================

Link: https://patch.msgid.link/20260412060346.142007-1-dongml2@chinatelecom.cn


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 46ffc1f7 f0e16ac7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ about these objects, including id, type and name.

The main use-case `bpf_inspect.py`_ covers is to show BPF programs of types
``BPF_PROG_TYPE_EXT`` and ``BPF_PROG_TYPE_TRACING`` attached to other BPF
programs via ``freplace``/``fentry``/``fexit`` mechanisms, since there is no
user-space API to get this information.
programs via ``freplace``/``fentry``/``fexit``/``fsession`` mechanisms, since
there is no user-space API to get this information.

Getting started
===============
+4 −0
Original line number Diff line number Diff line
@@ -207,6 +207,10 @@ described in more detail in the footnotes.
+                                           +                                        +----------------------------------+-----------+
|                                           |                                        | ``fexit.s+`` [#fentry]_          | Yes       |
+                                           +----------------------------------------+----------------------------------+-----------+
|                                           | ``BPF_TRACE_FSESSION``                 | ``fsession+`` [#fentry]_         |           |
+                                           +                                        +----------------------------------+-----------+
|                                           |                                        | ``fsession.s+`` [#fentry]_       | Yes       |
+                                           +----------------------------------------+----------------------------------+-----------+
|                                           | ``BPF_TRACE_ITER``                     | ``iter+`` [#iter]_               |           |
+                                           +                                        +----------------------------------+-----------+
|                                           |                                        | ``iter.s+`` [#iter]_             | Yes       |
+5 −5
Original line number Diff line number Diff line
@@ -10152,7 +10152,7 @@ static int check_get_func_ip(struct bpf_verifier_env *env)
	if (type == BPF_PROG_TYPE_TRACING) {
		if (!bpf_prog_has_trampoline(env->prog)) {
			verbose(env, "func %s#%d supported only for fentry/fexit/fmod_ret programs\n",
			verbose(env, "func %s#%d supported only for fentry/fexit/fsession/fmod_ret programs\n",
				func_id_name(func_id), func_id);
			return -ENOTSUPP;
		}
@@ -19135,7 +19135,7 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
	btf = tgt_prog ? tgt_prog->aux->btf : prog->aux->attach_btf;
	if (!btf) {
		bpf_log(log,
			"FENTRY/FEXIT program can only be attached to another program annotated with BTF\n");
			"Tracing program can only be attached to another program annotated with BTF\n");
		return -EINVAL;
	}
	t = btf_type_by_id(btf, btf_id);
@@ -19171,7 +19171,7 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
		if (aux->func && aux->func[subprog]->aux->exception_cb) {
			bpf_log(log,
				"%s programs cannot attach to exception callback\n",
				prog_extension ? "Extension" : "FENTRY/FEXIT");
				prog_extension ? "Extension" : "Tracing");
			return -EINVAL;
		}
		conservative = aux->func_info_aux[subprog].unreliable;
@@ -19260,7 +19260,7 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
	case BPF_TRACE_RAW_TP:
		if (tgt_prog) {
			bpf_log(log,
				"Only FENTRY/FEXIT progs are attachable to another BPF prog\n");
				"Only FENTRY/FEXIT/FSESSION progs are attachable to another BPF prog\n");
			return -EINVAL;
		}
		if (!btf_type_is_typedef(t)) {
@@ -19526,7 +19526,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
	}
	if (prog->sleepable && !can_be_sleepable(prog)) {
		verbose(env, "Only fentry/fexit/fmod_ret, lsm, iter, uprobe, and struct_ops programs can be sleepable\n");
		verbose(env, "Only fentry/fexit/fsession/fmod_ret, lsm, iter, uprobe, and struct_ops programs can be sleepable\n");
		return -EINVAL;
	}
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ PROG COMMANDS
|     **cgroup/sendmsg4** | **cgroup/sendmsg6** | **cgroup/sendmsg_unix** |
|     **cgroup/recvmsg4** | **cgroup/recvmsg6** | **cgroup/recvmsg_unix** | **cgroup/sysctl** |
|     **cgroup/getsockopt** | **cgroup/setsockopt** | **cgroup/sock_release** |
|     **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup**
|     **struct_ops** | **fentry** | **fexit** | **fsession** | **freplace** | **sk_lookup**
| }
| *ATTACH_TYPE* := {
|     **sk_msg_verdict** | **sk_skb_verdict** | **sk_skb_stream_verdict** |
+1 −1
Original line number Diff line number Diff line
@@ -501,7 +501,7 @@ _bpftool()
                                cgroup/post_bind4 cgroup/post_bind6 \
                                cgroup/sysctl cgroup/getsockopt \
                                cgroup/setsockopt cgroup/sock_release struct_ops \
                                fentry fexit freplace sk_lookup'
                                fentry fexit fsession freplace sk_lookup'
                            COMPREPLY=( $( compgen -W "$BPFTOOL_PROG_LOAD_TYPES" -- "$cur" ) )
                            return 0
                            ;;
Loading