args = kzalloc(sizeof(*args), GFP_KERNEL); if (!args) return ERR_PTR(-ENOMEM);
ctx_in = u64_to_user_ptr(kattr->test.ctx_in); if (copy_from_user(args->args, ctx_in, size_in)) goto out;
/* args[0] is 0 means state argument of test_N will be NULL */
u_state = u64_to_user_ptr(args->args[0]); if (u_state && copy_from_user(&args->state, u_state, sizeof(args->state))) goto out;
/* state needs to be NULL if args[0] is 0 */ if (args->args[0])
state = &args->state; return test(state, args->args[1], args->args[2],
args->args[3], args->args[4]);
}
staticconststruct bpf_ctx_arg_aux *find_ctx_arg_info(struct bpf_prog_aux *aux, int offset)
{ int i;
for (i = 0; i < aux->ctx_arg_info_size; i++) if (aux->ctx_arg_info[i].offset == offset) return &aux->ctx_arg_info[i];
return NULL;
}
/* There is only one check at the moment: * - zero should not be passed for pointer parameters not marked as nullable.
*/ staticint check_test_run_args(struct bpf_prog *prog, struct bpf_dummy_ops_test_args *args)
{ conststruct btf_type *func_proto = prog->aux->attach_func_proto;
/* Program is validated already, so there is no need * to check if t is NULL.
*/
t = btf_type_skip_modifiers(bpf_dummy_ops_btf, param->type, NULL); if (!btf_type_is_ptr(t)) continue;
offset = btf_ctx_arg_offset(bpf_dummy_ops_btf, func_proto, arg_no);
info = find_ctx_arg_info(prog->aux, offset); if (info && type_may_be_null(info->reg_type)) continue;
link = kzalloc(sizeof(*link), GFP_USER); if (!link) {
err = -ENOMEM; goto out;
} /* prog doesn't take the ownership of the reference from caller */
bpf_prog_inc(prog);
bpf_link_init(&link->link, BPF_LINK_TYPE_STRUCT_OPS, &bpf_struct_ops_link_lops, prog,
prog->expected_attach_type);
t = btf_type_by_id(reg->btf, reg->btf_id);
state = btf_type_by_id(reg->btf, type_id); if (t != state) {
bpf_log(log, "only access to bpf_dummy_ops_state is supported\n"); return -EACCES;
}
if (off + size > sizeof(struct bpf_dummy_ops_state)) {
bpf_log(log, "write access at off %d with size %d\n", off, size); return -EACCES;
}
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.