Skip to content

hornet: security, tooling and selftest fixes

Blaise Boscaccy linux-security-module 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11hornet: fix TOCTOU in signed program verificationDocumentation/admin-guide/LSM/Hornet.rst scripts/hornet/gen_sig.c security/hornet/hornet.asn1 +2 more+35 -1453 replies
2/11hornet: invert map set check logicsecurity/hornet/hornet_lsm.c+9 -153 replies
3/11hornet: fix off-by-one bug in max used maps checksecurity/hornet/hornet_lsm.c+3 -20 replies
4/11selftests: hornet: handle cross compilation and test skippingtools/testing/selftests/hornet/Makefile+89 -250 replies
5/11hornet: gen_sig: fix off-by-one check for used mapsscripts/hornet/gen_sig.c+2 -23 replies
6/11hornet: gen_sig: fix error string allocationsscripts/hornet/gen_sig.c+0 -30 replies
7/11hornet: gen_sig: check for bad allocationsscripts/hornet/gen_sig.c+34 -60 replies
8/11hornet: gen_sig: fix missing command line switchesscripts/hornet/gen_sig.c+4 -10 replies
9/11hornet: scripts: set a non-zero error code for usagescripts/hornet/extract-insn.sh scripts/hornet/extract-map.sh scripts/hornet/extract-skel.sh +1 more+20 -200 replies
10/11hornet: scripts: harden scripts to handle trailing whitespacescripts/hornet/extract-insn.sh scripts/hornet/extract-map.sh scripts/hornet/extract-skel.sh+3 -30 replies
11/11hornet: scripts: Improve argument handling and error messagesscripts/hornet/extract-insn.sh scripts/hornet/extract-map.sh scripts/hornet/extract-skel.sh+45 -90 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 00/11] hornet: security, tooling and selftest fixes

Patch 1 closes a TOCTOU race in signature verification. Map contents were hashed at the program-load hook and re-hashed at the program-run hook, leaving a window in which a sufficiently privileged attacker could mutate a map between the two checks and run a program whose maps no longer matched what was signed. The fix records the verified hashes on the prog at load time and, in security_bpf_prog, checks them against prog->aux->used_maps — the same map set the verifier and runtime resolve against — so the verified and executed sets cannot diverge. The per-map index in the signature format is no longer needed and is dropped; the check becomes a subset test. Reported by Eric Biggers.

Patches 2-3 fix two counting bugs in the same area: duplicate maps could satisfy the required hash count, and an off-by-one capped accepted maps at MAX_USED_MAPS.

Patches 4-11 are in response to sashiko feedback found here:
https://sashiko.dev/#/patchset/20260507191416.2984054-1-bboscaccy%40linux.microsoft.com

They provide some correctness fixes in the hornet tooling along with making the selftest behave under cross-compilation and skip cleanly when signing keys / bpftool / vmlinux BTF are unavailable, instead of breaking the global selftest build.

Blaise Boscaccy (11):
hornet: fix TOCTOU in signed program verification
hornet: invert map set check logic
hornet: fix off-by-one bug in max used maps check
selftests: hornet: handle cross compilation and test skipping
hornet: gen_sig: fix off-by-one check for used maps
hornet: gen_sig: fix error string allocations
hornet: gen_sig: check for bad allocations
hornet: gen_sig: fix missing command line switches
hornet: scripts: set a non-zero error code for usage
hornet: scripts: harden scripts to handle trailing whitespace
hornet: scripts: Improve argument handling and error messages

 Documentation/admin-guide/LSM/Hornet.rst |  39 +++---
 scripts/hornet/extract-insn.sh           |  24 ++--
 scripts/hornet/extract-map.sh            |  25 ++--
 scripts/hornet/extract-skel.sh           |  35 ++++--
 scripts/hornet/gen_sig.c                 |  61 ++++++----
 scripts/hornet/write-sig.sh              |  10 +-
 security/hornet/hornet.asn1              |   1 -
 security/hornet/hornet_lsm.c             | 148 ++++-------------------
 tools/testing/selftests/hornet/Makefile  | 114 +++++++++++++----
 9 files changed, 235 insertions(+), 222 deletions(-)
Signature · 1 line
2.53.0