tools/testing/selftests/bpf/prog_tests/verify_pkcs7_sig.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/verify_pkcs7_sig.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/verify_pkcs7_sig.c- Extension
.c- Size
- 12662 bytes
- Lines
- 544
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.herrno.hstdlib.hunistd.hendian.hlimits.hsys/stat.hsys/wait.hsys/mman.hlinux/keyctl.hsys/xattr.hlinux/fsverity.hlinux/module_signature.htest_progs.htest_verify_pkcs7_sig.skel.htest_sig_in_xattr.skel.h
Detected Declarations
struct datafunction libbpf_print_cbfunction _run_setup_processfunction populate_data_item_strfunction populate_data_item_modfunction test_verify_pkcs7_sig_from_mapfunction get_signature_sizefunction add_signature_to_xattrfunction test_open_filefunction test_pkcs7_sig_fsverityfunction test_verify_pkcs7_sig
Annotated Snippet
struct data {
__u8 data[MAX_DATA_SIZE];
__u32 data_len;
__u8 sig[MAX_SIG_SIZE];
__u32 sig_len;
};
static bool kfunc_not_supported;
static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt,
va_list args)
{
if (level == LIBBPF_WARN)
vprintf(fmt, args);
if (strcmp(fmt, "libbpf: extern (func ksym) '%s': not found in kernel or module BTFs\n"))
return 0;
if (strcmp(va_arg(args, char *), "bpf_verify_pkcs7_signature"))
return 0;
kfunc_not_supported = true;
return 0;
}
static int _run_setup_process(const char *setup_dir, const char *cmd)
{
int child_pid, child_status;
child_pid = fork();
if (child_pid == 0) {
execlp("./verify_sig_setup.sh", "./verify_sig_setup.sh", cmd,
setup_dir, NULL);
exit(errno);
} else if (child_pid > 0) {
waitpid(child_pid, &child_status, 0);
return WEXITSTATUS(child_status);
}
return -EINVAL;
}
static int populate_data_item_str(const char *tmp_dir, struct data *data_item)
{
struct stat st;
char data_template[] = "/tmp/dataXXXXXX";
char path[PATH_MAX];
int ret, fd, child_status, child_pid;
data_item->data_len = 4;
memcpy(data_item->data, "test", data_item->data_len);
fd = mkstemp(data_template);
if (fd == -1)
return -errno;
ret = write(fd, data_item->data, data_item->data_len);
close(fd);
if (ret != data_item->data_len) {
ret = -EIO;
goto out;
}
child_pid = fork();
if (child_pid == -1) {
ret = -errno;
goto out;
}
if (child_pid == 0) {
snprintf(path, sizeof(path), "%s/signing_key.pem", tmp_dir);
return execlp("./sign-file", "./sign-file", "-d", "sha256",
path, path, data_template, NULL);
}
waitpid(child_pid, &child_status, 0);
ret = WEXITSTATUS(child_status);
if (ret)
goto out;
snprintf(path, sizeof(path), "%s.p7s", data_template);
ret = stat(path, &st);
if (ret == -1) {
Annotation
- Immediate include surface: `stdio.h`, `errno.h`, `stdlib.h`, `unistd.h`, `endian.h`, `limits.h`, `sys/stat.h`, `sys/wait.h`.
- Detected declarations: `struct data`, `function libbpf_print_cb`, `function _run_setup_process`, `function populate_data_item_str`, `function populate_data_item_mod`, `function test_verify_pkcs7_sig_from_map`, `function get_signature_size`, `function add_signature_to_xattr`, `function test_open_file`, `function test_pkcs7_sig_fsverity`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.