• Roberto Sassu's avatar
    selftests/bpf: Add test for bpf_verify_pkcs7_signature() kfunc · fc975906
    Roberto Sassu authored
    Perform several tests to ensure the correct implementation of the
    bpf_verify_pkcs7_signature() kfunc.
    
    Do the tests with data signed with a generated testing key (by using
    sign-file from scripts/) and with the tcp_bic.ko kernel module if it is
    found in the system. The test does not fail if tcp_bic.ko is not found.
    
    First, perform an unsuccessful signature verification without data.
    
    Second, perform a successful signature verification with the session
    keyring and a new one created for testing.
    
    Then, ensure that permission and validation checks are done properly on the
    keyring provided to bpf_verify_pkcs7_signature(), despite those checks were
    deferred at the time the keyring was retrieved with bpf_lookup_user_key().
    The tests expect to encounter an error if the Search permission is removed
    from the keyring, or the keyring is expired.
    
    Finally, perform a successful and unsuccessful signature verification with
    the keyrings with pre-determined IDs (the last test fails because the key
    is not in the platform keyring).
    
    The test is currently in the deny list for s390x (JIT does not support
    calling kernel function).
    Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
    Link: https://lore.kernel.org/r/20220920075951.929132-13-roberto.sassu@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    fc975906
config 1.5 KB