eBPF-based security platform
testing: drop checks tied to ordinary mode
KP Singhed2ef1f643f0
diff --git a/Makefile.shirudo b/Makefile.shirudoindex 4bcbe0f4..63a5d9d5 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -589,7 +589,6 @@ verity-test-helpers: $(VERITY_TEST_HELPERS) build/verity-tests/shirudo-image-fauTEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-image-cli \testing/helper/test-image-cleanup \- testing/helper/test-mode-objects \testing/helper/test-image-config \testing/helper/test-config-image \testing/helper/test-config-update \@@ -820,10 +819,6 @@ testing/helper/test-image-cleanup: testing/helper/test-image-cleanup.c \-Wl,--wrap=shirudo_dm_verity_remove,--wrap=usleep \$(STATIC_LIBS) $(DYNAMIC_LIBS)-testing/helper/test-mode-objects: testing/helper/test-mode-objects.c \- $(call obj,util/loader.o) $(LIBBPF_A)- @printf ' CC $@\n'- $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lelf -lztest-helpers: $(TEST_HELPERS)diff --git a/testing/helper/test-conditions.c b/testing/helper/test-conditions.cindex 1d34a6aa..3a8886ad 100644--- a/testing/helper/test-conditions.c+++ b/testing/helper/test-conditions.c@@ -49,7 +49,6 @@ int main(int argc, char **argv)in.lsm_attached = lsm != 0;in.keyring_present = serial >= 0;in.keyring_mode = mode;- in.staging = in.lsm_attached && strcmp(mode, "bpf") != 0;in.keyring_serial = serial;in.keyring_serial_pinned = pinned;in.ks_seen = in.keyring_present;diff --git a/testing/helper/test-mode-objects.c b/testing/helper/test-mode-objects.cdeleted file mode 100644index 1e09b1b6..00000000--- a/testing/helper/test-mode-objects.c+++ /dev/null@@ -1,88 +0,0 @@-// SPDX-License-Identifier: BSD-2-Clause-/* Copyright (c) 2026 Authors of shirudo */--#include <gelf.h>-#include <stdbool.h>-#include <stdio.h>--#include <bpf/libbpf.h>--#include "util/loader.h"--static int symbols(const char *selection,- const struct shirudo_embedded_bpf *blob)-{- Elf_Scn *section = NULL;- Elf *elf;- int rc = 0;-- if (elf_version(EV_CURRENT) == EV_NONE)- return 1;- elf = elf_memory((char *)blob->data, blob->size);- if (!elf)- return 1;- while ((section = elf_nextscn(elf, section))) {- GElf_Shdr header;- Elf_Data *data;- size_t i;-- if (!gelf_getshdr(section, &header)) {- rc = 1;- break;- }- if (header.sh_type != SHT_SYMTAB)- continue;- data = elf_getdata(section, NULL);- if (!data || !header.sh_entsize) {- rc = 1;- break;- }- for (i = 1; i < header.sh_size / header.sh_entsize; i++) {- GElf_Sym symbol;- const char *name;-- if (!gelf_getsym(data, i, &symbol)) {- rc = 1;- break;- }- if (symbol.st_shndx != SHN_UNDEF)- continue;- name = elf_strptr(elf, header.sh_link, symbol.st_name);- if (!name) {- rc = 1;- break;- }- printf("extern %s %s\n", selection, name);- }- }- elf_end(elf);- return rc;-}--static int inspect(const char *selection,- const struct shirudo_embedded_bpf *blob)-{- struct bpf_program *program;- struct bpf_object *obj;- struct bpf_map *map;-- obj = bpf_object__open_mem(blob->data, blob->size, NULL);- if (!obj)- return 1;- printf("blob %s %s\n", selection, blob->name);- bpf_object__for_each_program(program, obj)- printf("program %s %s\n", selection,- bpf_program__name(program));- bpf_object__for_each_map(map, obj)- printf("map %s %s\n", selection, bpf_map__name(map));- bpf_object__close(obj);- return symbols(selection, blob);-}--int main(void)-{- return inspect("ordinary-admission", bpf2_blob(false)) ||- inspect("image-admission", bpf2_blob(true)) ||- inspect("ordinary-seal", seal_blob(false)) ||- inspect("image-seal", seal_blob(true));-}diff --git a/testing/t0053-mode-objects.sh b/testing/t0053-mode-objects.shdeleted file mode 100755index 7ba5e932..00000000--- a/testing/t0053-mode-objects.sh+++ /dev/null@@ -1,46 +0,0 @@-#!/bin/sh-# SPDX-License-Identifier: BSD-2-Clause-# Copyright (c) 2026 Authors of shirudo--cd "$(dirname "$0")"-. ./test-lib.sh--H=${SHIRUDO_TEST_MODE_OBJECTS_HELPER:-./helper/test-mode-objects}-W=$(mktemp)-trap 'rm -f "$W"' EXIT HUP INT TERM--test_expect_success 'embedded BPF selection keeps image hooks and maps out of ordinary mode' '- "$H" >"$W" && python3 - "$W" <<"PYTEST"-import sys-from collections import defaultdict--inventory = defaultdict(lambda: defaultdict(set))-for line in open(sys.argv[1]):- kind, selection, name = line.split()- inventory[selection][kind].add(name)-extra = {- "admission": {"shirudo_lsm_file_ioctl",- "shirudo_lsm_bdev_setintegrity",- "shirudo_lsm_bdev_free_security"},- "seal": {"shirudo_seal_mmap_file", "shirudo_seal_file_mprotect"},-}-common_maps = {"shirudo_bpffs_sb", "shirudo_tasks", "shirudo_tamper"}-for kind, blob in (("admission", "bpf2"), ("seal", "seal")):- ordinary = inventory["ordinary-" + kind]- image = inventory["image-" + kind]- assert ordinary["blob"] == {blob}, ordinary- assert image["blob"] == {blob + "_verity"}, image- assert ordinary["program"], ordinary- assert image["program"] == ordinary["program"] | extra[kind], inventory- assert ordinary["program"].isdisjoint(extra[kind]), ordinary- assert common_maps <= ordinary["map"], ordinary- image_maps = {"shirudo_devices", "shirudo_roots"}- assert common_maps | image_maps <= image["map"], image- assert image_maps.isdisjoint(ordinary["map"]), ordinary- assert "bpf_real_data_inode" not in ordinary["extern"], ordinary- if kind == "seal":- assert "bpf_real_data_inode" in image["extern"], image-PYTEST-'--test_done