• Aleksa Sarai's avatar
    codegen: stack: allow for inter-tid stack aggregation · c4a5de20
    Aleksa Sarai authored
    User-space stacks are quite special in regards to aggregation (and
    comparison) between processes. To a first approximation, each pid has a
    different memory mapping and thus pointers should not be compared or
    aggregated between pids[*]. With ASLR this becomes even more fun, and
    thus it is necessary to do usym()-style packing of the stackid for
    ustack (since bpf_get_stackid will give you a hash of the pointers --
    even in the ustack case).
    
    However, the kernel address space is the same regardless of current->pid
    -- and in many cases you want to aggregate between different processes
    (and if not, you can always do the packing yourself with @[tid,stack]).
    
    So, we only apply the packing when dealing with ustack. sym() already
    does the right thing.
    
    [*] This is more than slightly untrue -- really this depends on
        current->mm and ideally we would aggregate ustack on current->mm.
        Unfortunately this is not a luxury we have at the moment.
    Signed-off-by: default avatarAleksa Sarai <cyphar@cyphar.com>
    c4a5de20
codegen_llvm.cpp 49.5 KB