aya-rs / aya

Aya is an eBPF library for the Rust programming language, built with a focus on developer experience and operability.
https://aya-rs.dev/book/
Apache License 2.0
3.25k stars 290 forks source link

ebpf: fixed wrong bpf_get_stackid flags type #1067

Closed cppcoffee closed 1 month ago

cppcoffee commented 1 month ago

The flags parameter of the bpf_get_stackid function is of type u64.

netlify[bot] commented 1 month ago

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
Latest commit 35059fc0855e2374815aa87cd99acfbc7f0d693e
Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/6718ffab8c8e4d0008a49409
Deploy Preview https://deploy-preview-1067--aya-rs-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

cppcoffee commented 1 month ago

get_stackid flags are of u64 type, but got BPF_F_USER_STACK is u32.

let stack_id = unsafe { STACK_TRACES.get_stackid(ctx, BPF_F_USER_STACK as u64)? };

https://docs.rs/aya-ebpf/latest/aya_ebpf/maps/stack_trace/struct.StackTrace.html#method.get_stackid

/* flags for both BPF_FUNC_get_stackid and BPF_FUNC_get_stack. */
enum {
    BPF_F_SKIP_FIELD_MASK       = 0xffULL,
    BPF_F_USER_STACK        = (1ULL << 8),
/* flags used by BPF_FUNC_get_stackid only. */
    BPF_F_FAST_STACK_CMP        = (1ULL << 9),
    BPF_F_REUSE_STACKID     = (1ULL << 10),
/* flags used by BPF_FUNC_get_stack only. */
    BPF_F_USER_BUILD_ID     = (1ULL << 11),
};

The BPF_F_USER_STACK correct type is unsigned long long eq u64.