1. 13 Mar, 2020 6 commits
  2. 12 Mar, 2020 7 commits
  3. 11 Mar, 2020 3 commits
  4. 09 Mar, 2020 16 commits
  5. 05 Mar, 2020 6 commits
  6. 04 Mar, 2020 2 commits
    • Alexei Starovoitov's avatar
      Merge branch 'bpf_modify_ret' · 9ce60102
      Alexei Starovoitov authored
      KP Singh says:
      
      ====================
      v3 -> v4:
      
      * Fix a memory leak noticed by Daniel.
      
      v2 -> v3:
      
      * bpf_trampoline_update_progs -> bpf_trampoline_get_progs + const
        qualification.
      * Typos in commit messages.
      * Added Andrii's Acks.
      
      v1 -> v2:
      
      * Adressed Andrii's feedback.
      * Fixed a bug that Alexei noticed about nop generation.
      * Rebase.
      
      This was brought up in the KRSI v4 discussion and found to be useful
      both for security and tracing programs.
      
        https://lore.kernel.org/bpf/20200225193108.GB22391@chromium.org/
      
      The modify_return programs are allowed for security hooks (with an
      extra CAP_MAC_ADMIN check) and functions whitelisted for error
      injection (ALLOW_ERROR_INJECTION).
      
      The "security_" check is expected to be cleaned up with the KRSI patch
      series.
      
      Here is an example of how a fmod_ret program behaves:
      
      int func_to_be_attached(int a, int b)
      {  <--- do_fentry
      
      do_fmod_ret:
         <update ret by calling fmod_ret>
         if (ret != 0)
              goto do_fexit;
      
      original_function:
      
          <side_effects_happen_here>
      
      }  <--- do_fexit
      
      ALLOW_ERROR_INJECTION(func_to_be_attached, ERRNO)
      
      The fmod_ret program attached to this function can be defined as:
      
      SEC("fmod_ret/func_to_be_attached")
      int BPF_PROG(func_name, int a, int b, int ret)
      {
              // This will skip the original function logic.
              return -1;
      }
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      9ce60102
    • KP Singh's avatar
      bpf: Add selftests for BPF_MODIFY_RETURN · 3d08b6f2
      KP Singh authored
      Test for two scenarios:
      
        * When the fmod_ret program returns 0, the original function should
          be called along with fentry and fexit programs.
        * When the fmod_ret program returns a non-zero value, the original
          function should not be called, no side effect should be observed and
          fentry and fexit programs should be called.
      
      The result from the kernel function call and whether a side-effect is
      observed is returned via the retval attr of the BPF_PROG_TEST_RUN (bpf)
      syscall.
      Signed-off-by: default avatarKP Singh <kpsingh@google.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20200304191853.1529-8-kpsingh@chromium.org
      3d08b6f2