1. 12 Nov, 2021 30 commits
  2. 11 Nov, 2021 3 commits
  3. 10 Nov, 2021 1 commit
  4. 09 Nov, 2021 1 commit
  5. 08 Nov, 2021 2 commits
  6. 07 Nov, 2021 3 commits
    • Alexei Starovoitov's avatar
      Merge branch 'introduce bpf_find_vma' · 0cc78dcc
      Alexei Starovoitov authored
      Song Liu says:
      
      ====================
      
      Changes v4 => v5:
      1. Clean up and style change in 2/2. (Andrii)
      
      Changes v3 => v4:
      1. Move mmap_unlock_work to task_iter.c to fix build for .config without
         !CONFIG_PERF_EVENTS. (kernel test robot <lkp@intel.com>)
      
      Changes v2 => v3:
      1. Avoid using x86 only function in selftests. (Yonghong)
      2. Add struct file and struct vm_area_struct to btf_task_struct_ids, and
         use it in bpf_find_vma and stackmap.c. (Yonghong)
      3. Fix inaccurate comments. (Yonghong)
      
      Changes v1 => v2:
      1. Share irq_work with stackmap.c. (Daniel)
      2. Add tests for illegal writes to task/vma from the callback function.
         (Daniel)
      3. Other small fixes.
      
      Add helper bpf_find_vma. This can be used in some profiling use cases. It
      might also be useful for LSM.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      0cc78dcc
    • Song Liu's avatar
      selftests/bpf: Add tests for bpf_find_vma · f108662b
      Song Liu authored
      Add tests for bpf_find_vma in perf_event program and kprobe program. The
      perf_event program is triggered from NMI context, so the second call of
      bpf_find_vma() will return -EBUSY (irq_work busy). The kprobe program,
      on the other hand, does not have this constraint.
      
      Also add tests for illegal writes to task or vma from the callback
      function. The verifier should reject both cases.
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20211105232330.1936330-3-songliubraving@fb.com
      f108662b
    • Song Liu's avatar
      bpf: Introduce helper bpf_find_vma · 7c7e3d31
      Song Liu authored
      In some profiler use cases, it is necessary to map an address to the
      backing file, e.g., a shared library. bpf_find_vma helper provides a
      flexible way to achieve this. bpf_find_vma maps an address of a task to
      the vma (vm_area_struct) for this address, and feed the vma to an callback
      BPF function. The callback function is necessary here, as we need to
      ensure mmap_sem is unlocked.
      
      It is necessary to lock mmap_sem for find_vma. To lock and unlock mmap_sem
      safely when irqs are disable, we use the same mechanism as stackmap with
      build_id. Specifically, when irqs are disabled, the unlocked is postponed
      in an irq_work. Refactor stackmap.c so that the irq_work is shared among
      bpf_find_vma and stackmap helpers.
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Tested-by: default avatarHengqi Chen <hengqi.chen@gmail.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20211105232330.1936330-2-songliubraving@fb.com
      7c7e3d31