1. 17 Jan, 2018 8 commits
  2. 16 Jan, 2018 3 commits
    • Luis de Bethencourt's avatar
      samples/bpf: Fix trailing semicolon · 4c38f74c
      Luis de Bethencourt authored
      The trailing semicolon is an empty statement that does no operation.
      Removing it since it doesn't do anything.
      Signed-off-by: default avatarLuis de Bethencourt <luisbg@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      4c38f74c
    • Wei Yongjun's avatar
      bpf: cpumap: make some functions static · 0fe875c5
      Wei Yongjun authored
      Fixes the following sparse warnings:
      
      kernel/bpf/cpumap.c:146:6: warning:
       symbol '__cpu_map_queue_destructor' was not declared. Should it be static?
      kernel/bpf/cpumap.c:225:16: warning:
       symbol 'cpu_map_build_skb' was not declared. Should it be static?
      kernel/bpf/cpumap.c:340:26: warning:
       symbol '__cpu_map_entry_alloc' was not declared. Should it be static?
      kernel/bpf/cpumap.c:398:6: warning:
       symbol '__cpu_map_entry_free' was not declared. Should it be static?
      kernel/bpf/cpumap.c:441:6: warning:
       symbol '__cpu_map_entry_replace' was not declared. Should it be static?
      kernel/bpf/cpumap.c:454:5: warning:
       symbol 'cpu_map_delete_elem' was not declared. Should it be static?
      kernel/bpf/cpumap.c:467:5: warning:
       symbol 'cpu_map_update_elem' was not declared. Should it be static?
      kernel/bpf/cpumap.c:505:6: warning:
       symbol 'cpu_map_free' was not declared. Should it be static?
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      0fe875c5
    • Roman Gushchin's avatar
      bpftool: recognize BPF_PROG_TYPE_CGROUP_DEVICE programs · 45e5e121
      Roman Gushchin authored
      Bpftool doesn't recognize BPF_PROG_TYPE_CGROUP_DEVICE programs,
      so the prog show command prints the numeric type value:
      
      $ bpftool prog show
      1: type 15  name bpf_prog1  tag ac9f93dbfd6d9b74
      	loaded_at Jan 15/07:58  uid 0
      	xlated 96B  jited 105B  memlock 4096B
      
      This patch defines the corresponding textual representation:
      
      $ bpftool prog show
      1: cgroup_device  name bpf_prog1  tag ac9f93dbfd6d9b74
      	loaded_at Jan 15/07:58  uid 0
      	xlated 96B  jited 105B  memlock 4096B
      Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
      Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
      Cc: Quentin Monnet <quentin.monnet@netronome.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      45e5e121
  3. 14 Jan, 2018 16 commits
  4. 13 Jan, 2018 6 commits
    • Alexei Starovoitov's avatar
      Merge branch 'error-injection' · fdde5f3b
      Alexei Starovoitov authored
      Masami Hiramatsu says:
      
      ====================
      Here are the 5th version of patches to moving error injection
      table from kprobes. This version fixes a bug and update
      fail-function to support multiple function error injection.
      
      Here is the previous version:
      
      https://patchwork.ozlabs.org/cover/858663/
      
      Changes in v5:
       - [3/5] Fix a bug that within_error_injection returns false always.
       - [5/5] Update to support multiple function error injection.
      
      Thank you,
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      fdde5f3b
    • Masami Hiramatsu's avatar
      error-injection: Support fault injection framework · 4b1a29a7
      Masami Hiramatsu authored
      Support in-kernel fault-injection framework via debugfs.
      This allows you to inject a conditional error to specified
      function using debugfs interfaces.
      
      Here is the result of test script described in
      Documentation/fault-injection/fault-injection.txt
      
        ===========
        # ./test_fail_function.sh
        1+0 records in
        1+0 records out
        1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0227404 s, 46.1 MB/s
        btrfs-progs v4.4
        See http://btrfs.wiki.kernel.org for more information.
      
        Label:              (null)
        UUID:               bfa96010-12e9-4360-aed0-42eec7af5798
        Node size:          16384
        Sector size:        4096
        Filesystem size:    1001.00MiB
        Block group profiles:
          Data:             single            8.00MiB
          Metadata:         DUP              58.00MiB
          System:           DUP              12.00MiB
        SSD detected:       no
        Incompat features:  extref, skinny-metadata
        Number of devices:  1
        Devices:
           ID        SIZE  PATH
            1  1001.00MiB  /dev/loop2
      
        mount: mount /dev/loop2 on /opt/tmpmnt failed: Cannot allocate memory
        SUCCESS!
        ===========
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      4b1a29a7
    • Masami Hiramatsu's avatar
      error-injection: Add injectable error types · 663faf9f
      Masami Hiramatsu authored
      Add injectable error types for each error-injectable function.
      
      One motivation of error injection test is to find software flaws,
      mistakes or mis-handlings of expectable errors. If we find such
      flaws by the test, that is a program bug, so we need to fix it.
      
      But if the tester miss input the error (e.g. just return success
      code without processing anything), it causes unexpected behavior
      even if the caller is correctly programmed to handle any errors.
      That is not what we want to test by error injection.
      
      To clarify what type of errors the caller must expect for each
      injectable function, this introduces injectable error types:
      
       - EI_ETYPE_NULL : means the function will return NULL if it
      		    fails. No ERR_PTR, just a NULL.
       - EI_ETYPE_ERRNO : means the function will return -ERRNO
      		    if it fails.
       - EI_ETYPE_ERRNO_NULL : means the function will return -ERRNO
      		       (ERR_PTR) or NULL.
      
      ALLOW_ERROR_INJECTION() macro is expanded to get one of
      NULL, ERRNO, ERRNO_NULL to record the error type for
      each function. e.g.
      
       ALLOW_ERROR_INJECTION(open_ctree, ERRNO)
      
      This error types are shown in debugfs as below.
      
        ====
        / # cat /sys/kernel/debug/error_injection/list
        open_ctree [btrfs]	ERRNO
        io_ctl_init [btrfs]	ERRNO
        ====
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      663faf9f
    • Masami Hiramatsu's avatar
      error-injection: Separate error-injection from kprobe · 540adea3
      Masami Hiramatsu authored
      Since error-injection framework is not limited to be used
      by kprobes, nor bpf. Other kernel subsystems can use it
      freely for checking safeness of error-injection, e.g.
      livepatch, ftrace etc.
      So this separate error-injection framework from kprobes.
      
      Some differences has been made:
      
      - "kprobe" word is removed from any APIs/structures.
      - BPF_ALLOW_ERROR_INJECTION() is renamed to
        ALLOW_ERROR_INJECTION() since it is not limited for BPF too.
      - CONFIG_FUNCTION_ERROR_INJECTION is the config item of this
        feature. It is automatically enabled if the arch supports
        error injection feature for kprobe or ftrace etc.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      540adea3
    • Masami Hiramatsu's avatar
      tracing/kprobe: bpf: Compare instruction pointer with original one · 66665ad2
      Masami Hiramatsu authored
      Compare instruction pointer with original one on the
      stack instead using per-cpu bpf_kprobe_override flag.
      
      This patch also consolidates reset_current_kprobe() and
      preempt_enable_no_resched() blocks. Those can be done
      in one place.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      66665ad2
    • Masami Hiramatsu's avatar
      tracing/kprobe: bpf: Check error injectable event is on function entry · b4da3340
      Masami Hiramatsu authored
      Check whether error injectable event is on function entry or not.
      Currently it checks the event is ftrace-based kprobes or not,
      but that is wrong. It should check if the event is on the entry
      of target function. Since error injection will override a function
      to just return with modified return value, that operation must
      be done before the target function starts making stackframe.
      
      As a side effect, bpf error injection is no need to depend on
      function-tracer. It can work with sw-breakpoint based kprobe
      events too.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b4da3340
  5. 12 Jan, 2018 7 commits