bpf: Return hashes of maps in BPF_OBJ_GET_INFO_BY_FD
authorKP Singh <kpsingh@kernel.org>
Sun, 14 Sep 2025 21:51:35 +0000 (23:51 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 19 Sep 2025 02:11:42 +0000 (19:11 -0700)
commitea2e6467ac36bf3d785defc89e58269b15d182f7
tree36a844dc8effdd72fbbf357961b67783f9abd052
parent6c850cbca82c2d20bc1b1c5e0e1c25c515292abd
bpf: Return hashes of maps in BPF_OBJ_GET_INFO_BY_FD

Currently only array maps are supported, but the implementation can be
extended for other maps and objects. The hash is memoized only for
exclusive and frozen maps as their content is stable until the exclusive
program modifies the map.

This is required for BPF signing, enabling a trusted loader program to
verify a map's integrity. The loader retrieves
the map's runtime hash from the kernel and compares it against an
expected hash computed at build time.

Signed-off-by: KP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/r/20250914215141.15144-7-kpsingh@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/arraymap.c
kernel/bpf/syscall.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/progs/verifier_map_ptr.c