diff options
author | Song Liu <song@kernel.org> | 2023-11-29 15:44:17 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-12-01 16:21:03 -0800 |
commit | 1030e9154258b54e3c7dc07c39e7b6dcf24bc3d2 (patch) | |
tree | 0d7e27c7ea846503b8b95abaee14a85242a98347 /tools/testing/selftests/bpf/bpf_kfuncs.h | |
parent | 341f06fdddf72cd60a10945152f69f0f1d614519 (diff) | |
download | lwn-1030e9154258b54e3c7dc07c39e7b6dcf24bc3d2.tar.gz lwn-1030e9154258b54e3c7dc07c39e7b6dcf24bc3d2.zip |
selftests/bpf: Add test that uses fsverity and xattr to sign a file
This selftests shows a proof of concept method to use BPF LSM to enforce
file signature. This test is added to verify_pkcs7_sig, so that some
existing logic can be reused.
This file signature method uses fsverity, which provides reliable and
efficient hash (known as digest) of the file. The file digest is signed
with asymmetic key, and the signature is stored in xattr. At the run time,
BPF LSM reads file digest and the signature, and then checks them against
the public key.
Note that this solution does NOT require FS_VERITY_BUILTIN_SIGNATURES.
fsverity is only used to provide file digest. The signature verification
and access control is all implemented in BPF LSM.
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20231129234417.856536-7-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_kfuncs.h')
-rw-r--r-- | tools/testing/selftests/bpf/bpf_kfuncs.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selftests/bpf/bpf_kfuncs.h index c2c084a44eae..b4e78c1eb37b 100644 --- a/tools/testing/selftests/bpf/bpf_kfuncs.h +++ b/tools/testing/selftests/bpf/bpf_kfuncs.h @@ -58,4 +58,11 @@ void *bpf_rdonly_cast(void *obj, __u32 btf_id) __ksym; extern int bpf_get_file_xattr(struct file *file, const char *name, struct bpf_dynptr *value_ptr) __ksym; extern int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr *digest_ptr) __ksym; + +extern struct bpf_key *bpf_lookup_user_key(__u32 serial, __u64 flags) __ksym; +extern struct bpf_key *bpf_lookup_system_key(__u64 id) __ksym; +extern void bpf_key_put(struct bpf_key *key) __ksym; +extern int bpf_verify_pkcs7_signature(struct bpf_dynptr *data_ptr, + struct bpf_dynptr *sig_ptr, + struct bpf_key *trusted_keyring) __ksym; #endif |