if (!bpf_ksym_exists(bpf_task_acquire)) {
err = 3; return 0;
} if (!bpf_ksym_exists(bpf_testmod_test_mod_kfunc)) {
err = 4; return 0;
} if (bpf_ksym_exists(invalid_kfunc)) { /* the verifier's dead code elimination should remove this */
err = 5; asmvolatile ("goto -1"); /* for (;;); */
}
acquired = bpf_task_acquire(task); if (acquired)
bpf_task_release(acquired); else
err = 6;
return 0;
}
SEC("tp_btf/task_newtask") int BPF_PROG(test_task_kfunc_flavor_relo, struct task_struct *task, u64 clone_flags)
{ struct task_struct *acquired = NULL; int fake_ctx = 42;
if (bpf_ksym_exists(bpf_task_acquire___one)) {
acquired = bpf_task_acquire___one(task);
} elseif (bpf_ksym_exists(bpf_task_acquire___two)) { /* Here, bpf_object__resolve_ksym_func_btf_id's find_ksym_btf_id * call will find vmlinux's bpf_task_acquire, but subsequent * bpf_core_types_are_compat will fail
*/
acquired = bpf_task_acquire___two(task, &fake_ctx);
err = 3; return 0;
} elseif (bpf_ksym_exists(bpf_task_acquire___three)) { /* bpf_core_types_are_compat will fail similarly to above case */
acquired = bpf_task_acquire___three(&fake_ctx);
err = 4; return 0;
}
if (acquired)
bpf_task_release(acquired); else
err = 5; return 0;
}
SEC("tp_btf/task_newtask") int BPF_PROG(test_task_kfunc_flavor_relo_not_found, struct task_struct *task, u64 clone_flags)
{ /* Neither symbol should successfully resolve. * Success or failure of one ___flavor should not affect others
*/ if (bpf_ksym_exists(bpf_task_acquire___two))
err = 1; elseif (bpf_ksym_exists(bpf_task_acquire___three))
err = 2;
return 0;
}
SEC("tp_btf/task_newtask") int BPF_PROG(test_task_acquire_release_argument, struct task_struct *task, u64 clone_flags)
{ if (!is_test_kfunc_task()) return 0;
return test_acquire_release(task);
}
SEC("tp_btf/task_newtask") int BPF_PROG(test_task_acquire_release_current, struct task_struct *task, u64 clone_flags)
{ if (!is_test_kfunc_task()) return 0;
/* Stash a copy into local kptr and check if it is released recursively */
acquired = bpf_task_acquire(kptr); if (!acquired) {
err = 7;
bpf_obj_drop(local);
bpf_task_release(kptr); return 0;
}
bpf_probe_read_kernel(&refcnt, sizeof(refcnt), &acquired->rcu_users);
/* task->group_leader is listed as a trusted, non-NULL field of task struct. */
acquired = bpf_task_acquire(task->group_leader); if (acquired)
bpf_task_release(acquired); else
err = 1;
return 0;
}
SEC("syscall") int test_task_from_vpid_current(constvoid *ctx)
{ struct task_struct *current, *v_task;
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.