SEC("?raw_tp")
__success int force_clang_to_emit_btf_for_externs(void *ctx)
{ /* we need this as a workaround to enforce compiler emitting BTF * information for bpf_iter_num_{new,next,destroy}() kfuncs, * as, apparently, it doesn't emit it for symbols only referenced from * assembly (or cleanup attribute, for that matter, as well)
*/
bpf_repeat(0);
SEC("?raw_tp")
__failure __msg("expected an initialized iter_num as arg #0") int destroy_without_creating_fail(void *ctx)
{ /* init with zeros to stop verifier complaining about uninit stack */ struct bpf_iter_num iter;
SEC("?raw_tp")
__failure /* ensure there was a call to subprog, which might happen without __noinline */
__msg("returning from callee:")
__msg("Unreleased reference id=1") int leak_iter_from_subprog_fail(void *ctx)
{
subprog_with_iter();
asmvolatile ( /* Create a fork in logic, with general setup as follows: * - fallthrough (first) path is valid; * - branch (second) path is invalid. * Then depending on what we do in fallthrough vs branch path, * we try to detect bugs in func_states_equal(), regsafe(), * refsafe(), stack_safe(), and similar by tricking verifier * into believing that branch state is a valid subset of * a fallthrough state. Verifier should reject overall * validation, unless there is a bug somewhere in verifier * logic.
*/ "call %[bpf_get_prandom_u32];" "r6 = r0;" "call %[bpf_get_prandom_u32];" "r7 = r0;"
"if r6 > r7 goto bad;"/* fork */
/* spill r6 into stack slot of bpf_iter_num var */ "*(u64 *)(%[iter] + 0) = r6;"
"goto skip_bad;"
"bad:" /* create iterator in the same stack slot */ "r1 = %[iter];" "r2 = 0;" "r3 = 1000;" "call %[bpf_iter_num_new];"
/* but then forget about it and overwrite it back to r6 spill */ "*(u64 *)(%[iter] + 0) = r6;"
"skip_bad:" "goto +0;"/* force checkpoint */
/* corrupt stack slots, if they are really dynptr */ "*(u64 *)(%[iter] + 0) = r6;"
:
: __imm_ptr(iter),
__imm_addr(zero),
__imm(bpf_get_prandom_u32),
__imm(bpf_dynptr_from_mem),
ITER_HELPERS
: __clobber_common, "r6", "r7"
);
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.