staticstruct kfunc_test_params kfunc_tests[] = { /* failure cases: * if retval is 0 -> the program will fail to load and the error message is an error * if retval is not 0 -> the program can be loaded but running it will gives the * provided return value. The error message is thus the one * from a successful load
*/
SYSCALL_NULL_CTX_FAIL(kfunc_syscall_test_fail, -EINVAL, "processed 4 insns"),
SYSCALL_NULL_CTX_FAIL(kfunc_syscall_test_null_fail, -EINVAL, "processed 4 insns"),
TC_FAIL(kfunc_call_test_get_mem_fail_rdonly, 0, "R0 cannot write into rdonly_mem"),
TC_FAIL(kfunc_call_test_get_mem_fail_use_after_free, 0, "invalid mem access 'scalar'"),
TC_FAIL(kfunc_call_test_get_mem_fail_oob, 0, "min value is outside of the allowed memory range"),
TC_FAIL(kfunc_call_test_get_mem_fail_not_const, 0, "is not a const"),
TC_FAIL(kfunc_call_test_mem_acquire_fail, 0, "acquire kernel function does not return PTR_TO_BTF_ID"),
TC_FAIL(kfunc_call_test_pointer_arg_type_mismatch, 0, "arg#0 expected pointer to ctx, but got scalar"),
switch (param->test_type) { case syscall_test:
topts.ctx_in = &args;
topts.ctx_size_in = sizeof(args); /* fallthrough */ case syscall_null_ctx_test: break; case tc_test:
topts.data_in = &pkt_v4;
topts.data_size_in = sizeof(pkt_v4);
topts.repeat = 1; break;
}
skel = kfunc_call_fail__open_opts(&opts); if (!ASSERT_OK_PTR(skel, "kfunc_call_fail__open_opts")) goto cleanup;
prog = bpf_object__find_program_by_name(skel->obj, param->prog_name); if (!ASSERT_OK_PTR(prog, "bpf_object__find_program_by_name")) goto cleanup;
bpf_program__set_autoload(prog, true);
err = kfunc_call_fail__load(skel); if (!param->retval) { /* the verifier is supposed to complain and refuses to load */ if (!ASSERT_ERR(err, "unexpected load success")) goto out_err;
} else { /* the program is loaded but must dynamically fail */ if (!ASSERT_OK(err, "unexpected load error")) goto out_err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.