]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: support fsession for bpf_session_cookie
authorMenglong Dong <menglong8.dong@gmail.com>
Sat, 24 Jan 2026 06:20:00 +0000 (14:20 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 25 Jan 2026 02:49:36 +0000 (18:49 -0800)
commiteeee4239dbb155a98f8ba737324ac081acde8417
treee08fd21e3c1bb4e9f15d5214f5d8988b032128b3
parent27d89baa6da8e5e546585c53a959176d1302d46e
bpf: support fsession for bpf_session_cookie

Implement session cookie for fsession. The session cookies will be stored
in the stack, and the layout of the stack will look like this:
  return value -> 8 bytes
  argN -> 8 bytes
  ...
  arg1 -> 8 bytes
  nr_args -> 8 bytes
  ip (optional) -> 8 bytes
  cookie2 -> 8 bytes
  cookie1 -> 8 bytes

The offset of the cookie for the current bpf program, which is in 8-byte
units, is stored in the
"(((u64 *)ctx)[-1] >> BPF_TRAMP_COOKIE_INDEX_SHIFT) & 0xFF". Therefore, we
can get the session cookie with ((u64 *)ctx)[-offset].

Implement and inline the bpf_session_cookie() for the fsession in the
verifier.

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Link: https://lore.kernel.org/r/20260124062008.8657-6-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
kernel/bpf/verifier.c