Skip to content

Signed BPF + IPE Policies

KP Singh bpf linux-security-module 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13bpf: expose signature verdict to LSMs via bpf_prog_auxinclude/linux/bpf.h kernel/bpf/syscall.c+39 -00 replies
2/13bpf: include prog BTF in the signed loader signature scopeinclude/linux/btf.h kernel/bpf/btf.c kernel/bpf/check_btf.c +1 more+56 -200 replies
3/13bpf, libbpf: load prog BTF in the skel_internal loadertools/lib/bpf/skel_internal.h+43 -10 replies
4/13bpf: add bpf_loader_verify_metadata kfunckernel/bpf/helpers.c tools/bpf/bpftool/sign.c tools/lib/bpf/skel_internal.h+73 -260 replies
5/13bpf: compute prog->digest at BPF_PROG_LOAD entrykernel/bpf/syscall.c kernel/bpf/verifier.c+7 -41 reply
6/13bpf: resolve loader-style kfunc CALLs against prog BTFinclude/linux/bpf_verifier.h include/uapi/linux/bpf.h kernel/bpf/verifier.c +1 more+67 -31 reply
7/13libbpf: generate prog BTF for loader programstools/lib/bpf/bpf_gen_internal.h tools/lib/bpf/gen_loader.c tools/lib/bpf/libbpf.h+105 -280 replies
8/13bpftool gen: embed loader prog BTF in the lskel headertools/bpf/bpftool/gen.c+21 -00 replies
9/13lsm: add bpf_prog_load_post_integrity hookinclude/linux/lsm_hook_defs.h include/linux/security.h security/security.c+24 -01 reply
10/13bpf: invoke security_bpf_prog_load_post_integrity from the metadata kfunckernel/bpf/helpers.c+8 -00 replies
11/13ipe: add BPF program signature propertiessecurity/ipe/Kconfig security/ipe/audit.c security/ipe/eval.c +6 more+162 -00 replies
12/13ipe: gate post-integrity BPF program loadssecurity/ipe/audit.c security/ipe/hooks.c security/ipe/hooks.h +3 more+13 -00 replies
13/13selftests/bpf: add IPE BPF policy integration teststools/testing/selftests/bpf/test_signed_bpf_ipe.sh tools/testing/selftests/bpf/vmtest.sh+158 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 00/13] Signed BPF + IPE Policies

This series continues the "Signed BPF programs" work and adds the missing pieces needed for an LSM to do policy enforcement and addresses the concerns raised by the developers of Hornet.

One signing scheme, please.

BPF does not need a second signing scheme. It needs a policy framework that consumes the verdict the existing signing pipeline produces. Two parallel signing stacks is harmful UX for Cilium, bpftrace, systemd, distros, and everyone shipping signed lskels. Hornet has been NACK'd repeatedly by the BPF maintainers [1][2] on layering and TOCTOU grounds.

What this series adds

- prog->aux->sig (verdict + keyring) and prog->aux->is_kernel, populated by the syscall path before security_bpf_prog_load fires.
- bpf_loader_verify_metadata kfunc -- the metadata check is now kernel C code, not BPF bytecode. The verifier injects the calling prog->aux as an implicit argument via KF_IMPLICIT_ARGS.
- Loader-side prog BTF with BPF_PSEUDO_KFUNC_CALL_PROG_BTF so the kfunc CALL is reproducible across build hosts and resolved at load time.
- security_bpf_prog_load_post_integrity LSM hook, fired by the kfunc on a successful metadata check.
- IPE properties (bpf_signature, bpf_keyring, bpf_kernel) and two ops (BPF_PROG_LOAD, BPF_PROG_LOAD_POST_INTEGRITY).

This series address concerns raised by the Hornet developers:

* The metadata hash check should be in kernel C, not BPF bytecode -- Blaise Boscaccy [3]:

The bpf_loader_verify_metadata kfunc moves the hash check from inline BPF instructions into kernel C code.

* LSMs cannot observe the verification result at hook time -- Paul Moore [4]:

prog->aux->sig.verdict and sig.keyring are populated before any LSM hook runs. Furthermore, security_bpf_prog_load_post_integrity hook fires after the in-kernel hash check for consumers that want to observe or gate the post-integrity transition.

[1] Alexei Starovoitov, NACK on Hornet (TOCTOU + layering),
https://lore.kernel.org/all/CAADnVQJ1CRvTXBU771KaYzrx-vRaWF+k164DcFOqOsCxmuL+ig@mail.gmail.com/
[2] Daniel Borkmann, NACK on Hornet v3,

    https://lore.kernel.org/all/[email protected]/
[3] Blaise Boscaccy, Hornet v6 (C-side hash verification rationale),
    https://lore.kernel.org/all/[email protected]/
[4] Paul Moore, push for post-verifier observability,
    https://lore.kernel.org/all/CACYkzJ4+=3owK+ELD9Nw7Rrm-UajxXEw8kVtOTJJ+SNAXpsOpw@mail.gmail.com/

KP Singh (13):
bpf: expose signature verdict to LSMs via bpf_prog_aux
bpf: include prog BTF in the signed loader signature scope bpf, libbpf: load prog BTF in the skel_internal loader
bpf: add bpf_loader_verify_metadata kfunc
bpf: compute prog->digest at BPF_PROG_LOAD entry
bpf: resolve loader-style kfunc CALLs against prog BTF
libbpf: generate prog BTF for loader programs
bpftool gen: embed loader prog BTF in the lskel header
lsm: add bpf_prog_load_post_integrity hook
bpf: invoke security_bpf_prog_load_post_integrity from the metadata
kfunc
ipe: add BPF program signature properties
ipe: gate post-integrity BPF program loads selftests/bpf: add IPE BPF policy integration tests

 include/linux/bpf.h                           |  19 +++
 include/linux/bpf_verifier.h                  |   6 +
 include/linux/btf.h                           |   1 +
 include/linux/lsm_hook_defs.h                 |   1 +
 include/linux/security.h                      |   6 +
 include/uapi/linux/bpf.h                      |   5 +
 kernel/bpf/btf.c                              |   8 +
 kernel/bpf/check_btf.c                        |  18 +-
 kernel/bpf/helpers.c                          |  65 ++++++++
 kernel/bpf/syscall.c                          |  76 ++++++++-
 kernel/bpf/verifier.c                         |  58 ++++++-
 security/ipe/Kconfig                          |  14 ++
 security/ipe/audit.c                          |  13 ++
 security/ipe/eval.c                           |  57 +++++++
 security/ipe/eval.h                           |   5 +
 security/ipe/hooks.c                          |  42 +++++
 security/ipe/hooks.h                          |   9 +
 security/ipe/ipe.c                            |   4 +
 security/ipe/policy.h                         |  11 ++
 security/ipe/policy_parser.c                  |  20 +++
 security/security.c                           |  17 ++
 tools/bpf/bpftool/gen.c                       |  21 +++
 tools/bpf/bpftool/sign.c                      |  17 +-
 tools/include/uapi/linux/bpf.h                |   5 +
 tools/lib/bpf/bpf_gen_internal.h              |   2 +
 tools/lib/bpf/gen_loader.c                    | 127 +++++++++++---
 tools/lib/bpf/libbpf.h                        |   4 +-
 tools/lib/bpf/skel_internal.h                 |  67 +++++---
 .../selftests/bpf/test_signed_bpf_ipe.sh      | 156 ++++++++++++++++++
 tools/testing/selftests/bpf/vmtest.sh         |   4 +-
 30 files changed, 775 insertions(+), 83 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/test_signed_bpf_ipe.sh
Signature · 1 line
2.53.0