Skip to content
Snippets Groups Projects
  1. Nov 13, 2021
    • Kumar Kartikeya Dwivedi's avatar
      libbpf: Perform map fd cleanup for gen_loader in case of error · ba05fd36
      Kumar Kartikeya Dwivedi authored
      Alexei reported a fd leak issue in gen loader (when invoked from
      bpftool) [0]. When adding ksym support, map fd allocation was moved from
      stack to loader map, however I missed closing these fds (relevant when
      cleanup label is jumped to on error). For the success case, the
      allocated fd is returned in loader ctx, hence this problem is not
      noticed.
      
      Make three changes, first MAX_USED_MAPS in MAX_FD_ARRAY_SZ instead of
      MAX_USED_PROGS, the braino was not a problem until now for this case as
      we didn't try to close map fds (otherwise use of it would have tried
      closing 32 additional fds in ksym btf fd range). Then, do a cleanup for
      all nr_maps fds in cleanup label code, so that in case of error all
      temporary map fds from bpf_gen__map_create are closed.
      
      Then, adjust the cleanup label to only generate code for the required
      number of program and map fds.  To trim code for remaining program
      fds, lay out prog_fd array in stack in the end, so that we can
      directly skip the remaining instances.  Still stack size remains same,
      since changing that would require changes in a lot of places
      (including adjustment of stack_off macro), so nr_progs_sz variable is
      only used to track required number of iterations (and jump over
      cleanup size calculated from that), stack offset calculation remains
      unaffected.
      
      The difference for test_ksyms_module.o is as follows:
      libbpf: //prog cleanup iterations: before = 34, after = 5
      libbpf: //maps cleanup iterations: before = 64, after = 2
      
      Also, move allocation of gen->fd_array offset to bpf_gen__init. Since
      offset can now be 0, and we already continue even if add_data returns 0
      in case of failure, we do not need to distinguish between 0 offset and
      failure case 0, as we rely on bpf_gen__finish to check errors. We can
      also skip check for gen->fd_array in add_*_fd functions, since
      bpf_gen__init will take care of it.
      
        [0]: https://lore.kernel.org/bpf/CAADnVQJ6jSitKSNKyxOrUzwY2qDRX0sPkJ=VLGHuCLVJ=qOt9g@mail.gmail.com
      
      
      
      Fixes: 18f4fccb ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations")
      Reported-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211112232022.899074-1-memxor@gmail.com
      ba05fd36
  2. Nov 12, 2021
    • Sasha Levin's avatar
      tools/lib/lockdep: drop liblockdep · 7246f4dc
      Sasha Levin authored
      
      TL;DR: While a tool like liblockdep is useful, it probably doesn't
      belong within the kernel tree.
      
      liblockdep attempts to reuse kernel code both directly (by directly
      building the kernel's lockdep code) as well as indirectly (by using
      sanitized headers). This makes liblockdep an integral part of the
      kernel.
      
      It also makes liblockdep quite unique: while other userspace code might
      use sanitized headers, it generally doesn't attempt to use kernel code
      directly which means that changes on the kernel side of things don't
      affect (and break) it directly.
      
      All our workflows and tooling around liblockdep don't support this
      uniqueness. Changes that go into the kernel code aren't validated to not
      break in-tree userspace code.
      
      liblockdep ended up being very fragile, breaking over and over, to the
      point that living in the same tree as the lockdep code lost most of it's
      value.
      
      liblockdep should continue living in an external tree, syncing with
      the kernel often, in a controllable way.
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7246f4dc
  3. Nov 05, 2021
  4. Nov 02, 2021
  5. Nov 01, 2021
  6. Oct 28, 2021
  7. Oct 27, 2021
  8. Oct 26, 2021
  9. Oct 23, 2021
  10. Oct 22, 2021
  11. Oct 21, 2021
  12. Oct 20, 2021
  13. Oct 19, 2021
  14. Oct 14, 2021
  15. Oct 08, 2021
Loading