• Martin KaFai Lau's avatar
    bpf: Add array support to btf_struct_access · 7e3617a7
    Martin KaFai Lau authored
    This patch adds array support to btf_struct_access().
    It supports array of int, array of struct and multidimensional
    array.
    
    It also allows using u8[] as a scratch space.  For example,
    it allows access the "char cb[48]" with size larger than
    the array's element "char".  Another potential use case is
    "u64 icsk_ca_priv[]" in the tcp congestion control.
    
    btf_resolve_size() is added to resolve the size of any type.
    It will follow the modifier if there is any.  Please
    see the function comment for details.
    
    This patch also adds the "off < moff" check at the beginning
    of the for loop.  It is to reject cases when "off" is pointing
    to a "hole" in a struct.
    Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20191107180903.4097702-1-kafai@fb.com
    7e3617a7
btf.c 98.5 KB