1. 13 11月, 2020 1 次提交
  2. 12 11月, 2020 9 次提交
  3. 11 11月, 2020 10 次提交
    • A
      bpf: Compile out btf_parse_module() if module BTF is not enabled · 7112d127
      Andrii Nakryiko 提交于
      Make sure btf_parse_module() is compiled out if module BTFs are not enabled.
      
      Fixes: 36e68442 ("bpf: Load and verify kernel module BTFs")
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20201111040645.903494-1-andrii@kernel.org
      7112d127
    • A
      Merge branch 'Remove unused test_ipip.sh test and add missed' · 9600d623
      Alexei Starovoitov 提交于
      Hangbin Liu says:
      
      ====================
      
      In comment 173ca26e ("samples/bpf: add comprehensive ipip, ipip6,
      ip6ip6 test") we added some bpf tunnel tests. In commit 933a741e
      ("selftests/bpf: bpf tunnel test.") when we moved it to the current
      folder, we missed some points:
      
      1. ip6ip6 test is not added
      2. forgot to remove test_ipip.sh in sample folder
      3. TCP test code is not removed in test_tunnel_kern.c
      
      In this patch set I add back ip6ip6 test and remove unused code. I'm not sure
      if this should be net or net-next, so just set to net.
      
      Here is the test result:
      ```
      Testing IP6IP6 tunnel...
      PING ::11(::11) 56 data bytes
      
      --- ::11 ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 63ms
      rtt min/avg/max/mdev = 0.014/1028.308/2060.906/841.361 ms, pipe 2
      PING 1::11(1::11) 56 data bytes
      
      --- 1::11 ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 48ms
      rtt min/avg/max/mdev = 0.026/0.029/0.036/0.006 ms
      PING 1::22(1::22) 56 data bytes
      
      --- 1::22 ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 47ms
      rtt min/avg/max/mdev = 0.030/0.048/0.067/0.016 ms
      PASS: ip6ip6tnl
      ```
      
      v3:
      Add back ICMP check as Martin suggested.
      
      v2: Keep ip6ip6 section in test_tunnel_kern.c.
      ====================
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      9600d623
    • H
      samples/bpf: Remove unused test_ipip.sh · e2215b05
      Hangbin Liu 提交于
      The tcbpf2_kern.o and related kernel sections are moved to bpf
      selftest folder since b05cd740 ("samples/bpf: remove the bpf tunnel
      testsuite."). Remove this one as well.
      
      Fixes: b05cd740 ("samples/bpf: remove the bpf tunnel testsuite.")
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20201110015013.1570716-3-liuhangbin@gmail.com
      e2215b05
    • H
      selftest/bpf: Add missed ip6ip6 test back · 58cfa49c
      Hangbin Liu 提交于
      In comment 173ca26e ("samples/bpf: add comprehensive ipip, ipip6,
      ip6ip6 test") we added ip6ip6 test for bpf tunnel testing. But in commit
      933a741e ("selftests/bpf: bpf tunnel test.") when we moved it to
      the current folder, we didn't add it.
      
      This patch add the ip6ip6 test back to bpf tunnel test. Update the ipip6's
      topology for both IPv4 and IPv6 testing. Since iperf test is removed as
      currect framework simplified it in purpose, I also removed unused tcp
      checkings in test_tunnel_kern.c.
      
      Fixes: 933a741e ("selftests/bpf: bpf tunnel test.")
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20201110015013.1570716-2-liuhangbin@gmail.com
      58cfa49c
    • A
      Merge branch 'Integrate kernel module BTF support' · 0e6f601e
      Alexei Starovoitov 提交于
      Andrii Nakryiko says:
      
      ====================
      
      This patch set adds BTF generation for kernel modules using a compact split
      BTF approach. Respective patches have all the details.
      
      Kernel module BTFs rely on pahole's split BTF support, which is added in [0]
      and will be available starting from v1.19. Support for it is detected
      automatically during kernel build time.
      
      This patch set implements in-kernel support for split BTF loading and
      validation. It also extends GET_OBJ_INFO API for BTFs to return BTF's module
      name and a flag whether BTF itself is in-kernel or user-provided. vmlinux BTF
      is also exposed to user-space through the same BTF object iteration APIs.
      
      Follow up patch set will utilize the fact that vmlinux and module BTFs now
      have associated ID to provide ability to attach BPF fentry/fexit/etc programs
      to functions defined in kernel modules.
      
      bpftool is also extended to show module/vmlinux BTF's name.
      
        [0] https://patchwork.kernel.org/project/netdevbpf/list/?series=378699&state=*
      
      v3->v4:
        - copy_to_user() on ENOSPC in btf_get_info_by_fd() (Martin);
      v2->v3:
        - get rid of unnecessary gotos (Song);
      v2->v1:
        - drop WARNs, add fewer pr_warn()'s instead (Greg);
        - properly initialize sysfs binary attribute structure (Greg);
        - add __maybe_unused to any_section_objs, used conditionally by module BTF;
      rfc->v1:
        - CONFIG_DEBUG_INFO_BTF_MODULES is derived automatically (Alexei);
        - vmlinux BTF now has explicit "vmlinux" name (Alexei);
        - added sysfs ABI documentation for /sys/kernel/btf/<module> (Greg).
      
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      ====================
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      0e6f601e
    • A
      tools/bpftool: Add support for in-kernel and named BTF in `btf show` · cecaf4a0
      Andrii Nakryiko 提交于
      Display vmlinux BTF name and kernel module names when listing available BTFs
      on the system.
      
      In human-readable output mode, module BTFs are reported with "name
      [module-name]", while vmlinux BTF will be reported as "name [vmlinux]".
      Square brackets are added by bpftool and follow kernel convention when
      displaying modules in human-readable text outputs.
      
      [vmuser@archvm bpf]$ sudo ../../../bpf/bpftool/bpftool btf s
      1: name [vmlinux]  size 4082281B
      6: size 2365B  prog_ids 8,6  map_ids 3
      7: name [button]  size 46895B
      8: name [pcspkr]  size 42328B
      9: name [serio_raw]  size 39375B
      10: name [floppy]  size 57185B
      11: name [i2c_core]  size 76186B
      12: name [crc32c_intel]  size 16036B
      13: name [i2c_piix4]  size 50497B
      14: name [irqbypass]  size 14124B
      15: name [kvm]  size 197985B
      16: name [kvm_intel]  size 123564B
      17: name [cryptd]  size 42466B
      18: name [crypto_simd]  size 17187B
      19: name [glue_helper]  size 39205B
      20: name [aesni_intel]  size 41034B
      25: size 36150B
              pids bpftool(2519)
      
      In JSON mode, two fields (boolean "kernel" and string "name") are reported for
      each BTF object. vmlinux BTF is reported with name "vmlinux" (kernel itself
      returns and empty name for vmlinux BTF).
      
      [vmuser@archvm bpf]$ sudo ../../../bpf/bpftool/bpftool btf s -jp
      [{
              "id": 1,
              "size": 4082281,
              "prog_ids": [],
              "map_ids": [],
              "kernel": true,
              "name": "vmlinux"
          },{
              "id": 6,
              "size": 2365,
              "prog_ids": [8,6
              ],
              "map_ids": [3
              ],
              "kernel": false
          },{
              "id": 7,
              "size": 46895,
              "prog_ids": [],
              "map_ids": [],
              "kernel": true,
              "name": "button"
          },{
      
      ...
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Link: https://lore.kernel.org/bpf/20201110011932.3201430-6-andrii@kernel.org
      cecaf4a0
    • A
      bpf: Load and verify kernel module BTFs · 36e68442
      Andrii Nakryiko 提交于
      Add kernel module listener that will load/validate and unload module BTF.
      Module BTFs gets ID generated for them, which makes it possible to iterate
      them with existing BTF iteration API. They are given their respective module's
      names, which will get reported through GET_OBJ_INFO API. They are also marked
      as in-kernel BTFs for tooling to distinguish them from user-provided BTFs.
      
      Also, similarly to vmlinux BTF, kernel module BTFs are exposed through
      sysfs as /sys/kernel/btf/<module-name>. This is convenient for user-space
      tools to inspect module BTF contents and dump their types with existing tools:
      
      [vmuser@archvm bpf]$ ls -la /sys/kernel/btf
      total 0
      drwxr-xr-x  2 root root       0 Nov  4 19:46 .
      drwxr-xr-x 13 root root       0 Nov  4 19:46 ..
      
      ...
      
      -r--r--r--  1 root root     888 Nov  4 19:46 irqbypass
      -r--r--r--  1 root root  100225 Nov  4 19:46 kvm
      -r--r--r--  1 root root   35401 Nov  4 19:46 kvm_intel
      -r--r--r--  1 root root     120 Nov  4 19:46 pcspkr
      -r--r--r--  1 root root     399 Nov  4 19:46 serio_raw
      -r--r--r--  1 root root 4094095 Nov  4 19:46 vmlinux
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: https://lore.kernel.org/bpf/20201110011932.3201430-5-andrii@kernel.org
      36e68442
    • A
      kbuild: Build kernel module BTFs if BTF is enabled and pahole supports it · 5f9ae91f
      Andrii Nakryiko 提交于
      Detect if pahole supports split BTF generation, and generate BTF for each
      selected kernel module, if it does. This is exposed to Makefiles and C code as
      CONFIG_DEBUG_INFO_BTF_MODULES flag.
      
      Kernel module BTF has to be re-generated if either vmlinux's BTF changes or
      module's .ko changes. To achieve that, I needed a helper similar to
      if_changed, but that would allow to filter out vmlinux from the list of
      updated dependencies for .ko building. I've put it next to the only place that
      uses and needs it, but it might be a better idea to just add it along the
      other if_changed variants into scripts/Kbuild.include.
      
      Each kernel module's BTF deduplication is pretty fast, as it does only
      incremental BTF deduplication on top of already deduplicated vmlinux BTF. To
      show the added build time, I've first ran make only just built kernel (to
      establish the baseline) and then forced only BTF re-generation, without
      regenerating .ko files. The build was performed with -j60 parallelization on
      56-core machine. The final time also includes bzImage building, so it's not
      a pure BTF overhead.
      
      $ time make -j60
      ...
      make -j60  27.65s user 10.96s system 782% cpu 4.933 total
      $ touch ~/linux-build/default/vmlinux && time make -j60
      ...
      make -j60  123.69s user 27.85s system 1566% cpu 9.675 total
      
      So 4.6 seconds real time, with noticeable part spent in compressed vmlinux and
      bzImage building.
      
      To show size savings, I've built my kernel configuration with about 700 kernel
      modules with full BTF per each kernel module (without deduplicating against
      vmlinux) and with split BTF against deduplicated vmlinux (approach in this
      patch). Below are top 10 modules with biggest BTF sizes. And total size of BTF
      data across all kernel modules.
      
      It shows that split BTF "compresses" 115MB down to 5MB total. And the biggest
      kernel modules get a downsize from 500-570KB down to 200-300KB.
      
      FULL BTF
      ========
      
      $ for f in $(find . -name '*.ko'); do size -A -d $f | grep BTF | awk '{print $2}'; done | awk '{ s += $1 } END { print s }'
      115710691
      
      $ for f in $(find . -name '*.ko'); do printf "%s %d\n" $f $(size -A -d $f | grep BTF | awk '{print $2}'); done | sort -nr -k2 | head -n10
      ./drivers/gpu/drm/i915/i915.ko 570570
      ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko 520240
      ./drivers/gpu/drm/radeon/radeon.ko 503849
      ./drivers/infiniband/hw/mlx5/mlx5_ib.ko 491777
      ./fs/xfs/xfs.ko 411544
      ./drivers/net/ethernet/intel/i40e/i40e.ko 403904
      ./drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko 398754
      ./drivers/infiniband/core/ib_core.ko 397224
      ./fs/cifs/cifs.ko 386249
      ./fs/nfsd/nfsd.ko 379738
      
      SPLIT BTF
      =========
      
      $ for f in $(find . -name '*.ko'); do size -A -d $f | grep BTF | awk '{print $2}'; done | awk '{ s += $1 } END { print s }'
      5194047
      
      $ for f in $(find . -name '*.ko'); do printf "%s %d\n" $f $(size -A -d $f | grep BTF | awk '{print $2}'); done | sort -nr -k2 | head -n10
      ./drivers/gpu/drm/i915/i915.ko 293206
      ./drivers/gpu/drm/radeon/radeon.ko 282103
      ./fs/xfs/xfs.ko 222150
      ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko 198503
      ./drivers/infiniband/hw/mlx5/mlx5_ib.ko 198356
      ./drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko 113444
      ./fs/cifs/cifs.ko 109379
      ./arch/x86/kvm/kvm.ko 100225
      ./drivers/gpu/drm/drm.ko 94827
      ./drivers/infiniband/core/ib_core.ko 91188
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20201110011932.3201430-4-andrii@kernel.org
      5f9ae91f
    • A
      bpf: Assign ID to vmlinux BTF and return extra info for BTF in GET_OBJ_INFO · 53297220
      Andrii Nakryiko 提交于
      Allocate ID for vmlinux BTF. This makes it visible when iterating over all BTF
      objects in the system. To allow distinguishing vmlinux BTF (and later kernel
      module BTF) from user-provided BTFs, expose extra kernel_btf flag, as well as
      BTF name ("vmlinux" for vmlinux BTF, will equal to module's name for module
      BTF).  We might want to later allow specifying BTF name for user-provided BTFs
      as well, if that makes sense. But currently this is reserved only for
      in-kernel BTFs.
      
      Having in-kernel BTFs exposed IDs will allow to extend BPF APIs that require
      in-kernel BTF type with ability to specify BTF types from kernel modules, not
      just vmlinux BTF. This will be implemented in a follow up patch set for
      fentry/fexit/fmod_ret/lsm/etc.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201110011932.3201430-3-andrii@kernel.org
      53297220
    • A
      bpf: Add in-kernel split BTF support · 951bb646
      Andrii Nakryiko 提交于
      Adjust in-kernel BTF implementation to support a split BTF mode of operation.
      Changes are mostly mirroring libbpf split BTF changes, with the exception of
      start_id being 0 for in-kernel implementation due to simpler read-only mode.
      
      Otherwise, for split BTF logic, most of the logic of jumping to base BTF,
      where necessary, is encapsulated in few helper functions. Type numbering and
      string offset in a split BTF are logically continuing where base BTF ends, so
      most of the high-level logic is kept without changes.
      
      Type verification and size resolution is only doing an added resolution of new
      split BTF types and relies on already cached size and type resolution results
      in the base BTF.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201110011932.3201430-2-andrii@kernel.org
      951bb646
  4. 10 11月, 2020 3 次提交
  5. 07 11月, 2020 10 次提交
  6. 06 11月, 2020 7 次提交
    • F
      bpf: Lift hashtab key_size limit · c6bde958
      Florian Lehner 提交于
      Currently key_size of hashtab is limited to MAX_BPF_STACK.
      As the key of hashtab can also be a value from a per cpu map it can be
      larger than MAX_BPF_STACK.
      
      The use-case for this patch originates to implement allow/disallow
      lists for files and file paths. The maximum length of file paths is
      defined by PATH_MAX with 4096 chars including nul.
      This limit exceeds MAX_BPF_STACK.
      
      Changelog:
      
      v5:
       - Fix cast overflow
      
      v4:
       - Utilize BPF skeleton in tests
       - Rebase
      
      v3:
       - Rebase
      
      v2:
       - Add a test for bpf side
      Signed-off-by: NFlorian Lehner <dev@der-flo.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20201029201442.596690-1-dev@der-flo.net
      c6bde958
    • A
      Merge branch 'libbpf: split BTF support' · b6b466a8
      Alexei Starovoitov 提交于
      Andrii Nakryiko says:
      
      ====================
      This patch set adds support for generating and deduplicating split BTF. This
      is an enhancement to the BTF, which allows to designate one BTF as the "base
      BTF" (e.g., vmlinux BTF), and one or more other BTFs as "split BTF" (e.g.,
      kernel module BTF), which are building upon and extending base BTF with extra
      types and strings.
      
      Once loaded, split BTF appears as a single unified BTF superset of base BTF,
      with continuous and transparent numbering scheme. This allows all the existing
      users of BTF to work correctly and stay agnostic to the base/split BTFs
      composition.  The only difference is in how to instantiate split BTF: it
      requires base BTF to be alread instantiated and passed to btf__new_xxx_split()
      or btf__parse_xxx_split() "constructors" explicitly.
      
      This split approach is necessary if we are to have a reasonably-sized kernel
      module BTFs. By deduping each kernel module's BTF individually, resulting
      module BTFs contain copies of a lot of kernel types that are already present
      in vmlinux BTF. Even those single copies result in a big BTF size bloat. On my
      kernel configuration with 700 modules built, non-split BTF approach results in
      115MBs of BTFs across all modules. With split BTF deduplication approach,
      total size is down to 5.2MBs total, which is on part with vmlinux BTF (at
      around 4MBs). This seems reasonable and practical. As to why we'd need kernel
      module BTFs, that should be pretty obvious to anyone using BPF at this point,
      as it allows all the BTF-powered features to be used with kernel modules:
      tp_btf, fentry/fexit/fmod_ret, lsm, bpf_iter, etc.
      
      This patch set is a pre-requisite to adding split BTF support to pahole, which
      is a prerequisite to integrating split BTF into the Linux kernel build setup
      to generate BTF for kernel modules. The latter will come as a follow-up patch
      series once this series makes it to the libbpf and pahole makes use of it.
      
      Patch #4 introduces necessary basic support for split BTF into libbpf APIs.
      Patch #8 implements minimal changes to BTF dedup algorithm to allow
      deduplicating split BTFs. Patch #11 adds extra -B flag to bpftool to allow to
      specify the path to base BTF for cases when one wants to dump or inspect split
      BTF. All the rest are refactorings, clean ups, bug fixes and selftests.
      
      v1->v2:
        - addressed Song's feedback.
      ====================
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      b6b466a8
    • A
      tools/bpftool: Add bpftool support for split BTF · 75fa1777
      Andrii Nakryiko 提交于
      Add ability to work with split BTF by providing extra -B flag, which allows to
      specify the path to the base BTF file.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201105043402.2530976-12-andrii@kernel.org
      75fa1777
    • A
      selftests/bpf: Add split BTF dedup selftests · 232338fa
      Andrii Nakryiko 提交于
      Add selftests validating BTF deduplication for split BTF case. Add a helper
      macro that allows to validate entire BTF with raw BTF dump, not just
      type-by-type. This saves tons of code and complexity.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201105043402.2530976-11-andrii@kernel.org
      232338fa
    • A
      libbpf: Accomodate DWARF/compiler bug with duplicated identical arrays · 6b6e6b1d
      Andrii Nakryiko 提交于
      In some cases compiler seems to generate distinct DWARF types for identical
      arrays within the same CU. That seems like a bug, but it's already out there
      and breaks type graph equivalence checks, so accommodate it anyway by checking
      for identical arrays, regardless of their type ID.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201105043402.2530976-10-andrii@kernel.org
      6b6e6b1d
    • A
      libbpf: Support BTF dedup of split BTFs · f86524ef
      Andrii Nakryiko 提交于
      Add support for deduplication split BTFs. When deduplicating split BTF, base
      BTF is considered to be immutable and can't be modified or adjusted. 99% of
      BTF deduplication logic is left intact (module some type numbering adjustments).
      There are only two differences.
      
      First, each type in base BTF gets hashed (expect VAR and DATASEC, of course,
      those are always considered to be self-canonical instances) and added into
      a table of canonical table candidates. Hashing is a shallow, fast operation,
      so mostly eliminates the overhead of having entire base BTF to be a part of
      BTF dedup.
      
      Second difference is very critical and subtle. While deduplicating split BTF
      types, it is possible to discover that one of immutable base BTF BTF_KIND_FWD
      types can and should be resolved to a full STRUCT/UNION type from the split
      BTF part.  This is, obviously, can't happen because we can't modify the base
      BTF types anymore. So because of that, any type in split BTF that directly or
      indirectly references that newly-to-be-resolved FWD type can't be considered
      to be equivalent to the corresponding canonical types in base BTF, because
      that would result in a loss of type resolution information. So in such case,
      split BTF types will be deduplicated separately and will cause some
      duplication of type information, which is unavoidable.
      
      With those two changes, the rest of the algorithm manages to deduplicate split
      BTF correctly, pointing all the duplicates to their canonical counter-parts in
      base BTF, but also is deduplicating whatever unique types are present in split
      BTF on their own.
      
      Also, theoretically, split BTF after deduplication could end up with either
      empty type section or empty string section. This is handled by libbpf
      correctly in one of previous patches in the series.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201105043402.2530976-9-andrii@kernel.org
      f86524ef
    • A
      libbpf: Fix BTF data layout checks and allow empty BTF · d8123624
      Andrii Nakryiko 提交于
      Make data section layout checks stricter, disallowing overlap of types and
      strings data.
      
      Additionally, allow BTFs with no type data. There is nothing inherently wrong
      with having BTF with no types (put potentially with some strings). This could
      be a situation with kernel module BTFs, if module doesn't introduce any new
      type information.
      
      Also fix invalid offset alignment check for btf->hdr->type_off.
      
      Fixes: 8a138aed ("bpf: btf: Add BTF support to libbpf")
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20201105043402.2530976-8-andrii@kernel.org
      d8123624