Skip to content
Snippets Groups Projects
  1. Nov 13, 2020
  2. Oct 09, 2020
  3. Oct 01, 2020
    • Jens Axboe's avatar
      io_uring: don't rely on weak ->files references · 0f212204
      Jens Axboe authored
      
      Grab actual references to the files_struct. To avoid circular references
      issues due to this, we add a per-task note that keeps track of what
      io_uring contexts a task has used. When the tasks execs or exits its
      assigned files, we cancel requests based on this tracking.
      
      With that, we can grab proper references to the files table, and no
      longer need to rely on stashing away ring_fd and ring_file to check
      if the ring_fd may have been closed.
      
      Cc: stable@vger.kernel.org # v5.5+
      Reviewed-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      0f212204
  4. Sep 24, 2020
  5. Sep 19, 2020
  6. Sep 18, 2020
  7. Sep 08, 2020
  8. Sep 04, 2020
  9. Sep 01, 2020
  10. Aug 28, 2020
    • Alexei Starovoitov's avatar
      bpf: Introduce sleepable BPF programs · 1e6c62a8
      Alexei Starovoitov authored
      
      Introduce sleepable BPF programs that can request such property for themselves
      via BPF_F_SLEEPABLE flag at program load time. In such case they will be able
      to use helpers like bpf_copy_from_user() that might sleep. At present only
      fentry/fexit/fmod_ret and lsm programs can request to be sleepable and only
      when they are attached to kernel functions that are known to allow sleeping.
      
      The non-sleepable programs are relying on implicit rcu_read_lock() and
      migrate_disable() to protect life time of programs, maps that they use and
      per-cpu kernel structures used to pass info between bpf programs and the
      kernel. The sleepable programs cannot be enclosed into rcu_read_lock().
      migrate_disable() maps to preempt_disable() in non-RT kernels, so the progs
      should not be enclosed in migrate_disable() as well. Therefore
      rcu_read_lock_trace is used to protect the life time of sleepable progs.
      
      There are many networking and tracing program types. In many cases the
      'struct bpf_prog *' pointer itself is rcu protected within some other kernel
      data structure and the kernel code is using rcu_dereference() to load that
      program pointer and call BPF_PROG_RUN() on it. All these cases are not touched.
      Instead sleepable bpf programs are allowed with bpf trampoline only. The
      program pointers are hard-coded into generated assembly of bpf trampoline and
      synchronize_rcu_tasks_trace() is used to protect the life time of the program.
      The same trampoline can hold both sleepable and non-sleepable progs.
      
      When rcu_read_lock_trace is held it means that some sleepable bpf program is
      running from bpf trampoline. Those programs can use bpf arrays and preallocated
      hash/lru maps. These map types are waiting on programs to complete via
      synchronize_rcu_tasks_trace();
      
      Updates to trampoline now has to do synchronize_rcu_tasks_trace() and
      synchronize_rcu_tasks() to wait for sleepable progs to finish and for
      trampoline assembly to finish.
      
      This is the first step of introducing sleepable progs. Eventually dynamically
      allocated hash maps can be allowed and networking program types can become
      sleepable too.
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarKP Singh <kpsingh@google.com>
      Link: https://lore.kernel.org/bpf/20200827220114.69225-3-alexei.starovoitov@gmail.com
      1e6c62a8
  11. Aug 20, 2020
    • Alexei Starovoitov's avatar
      bpf: Add kernel module with user mode driver that populates bpffs. · d71fa5c9
      Alexei Starovoitov authored
      
      Add kernel module with user mode driver that populates bpffs with
      BPF iterators.
      
      $ mount bpffs /my/bpffs/ -t bpf
      $ ls -la /my/bpffs/
      total 4
      drwxrwxrwt  2 root root    0 Jul  2 00:27 .
      drwxr-xr-x 19 root root 4096 Jul  2 00:09 ..
      -rw-------  1 root root    0 Jul  2 00:27 maps.debug
      -rw-------  1 root root    0 Jul  2 00:27 progs.debug
      
      The user mode driver will load BPF Type Formats, create BPF maps, populate BPF
      maps, load two BPF programs, attach them to BPF iterators, and finally send two
      bpf_link IDs back to the kernel.
      The kernel will pin two bpf_links into newly mounted bpffs instance under
      names "progs.debug" and "maps.debug". These two files become human readable.
      
      $ cat /my/bpffs/progs.debug
        id name            attached
        11 dump_bpf_map    bpf_iter_bpf_map
        12 dump_bpf_prog   bpf_iter_bpf_prog
        27 test_pkt_access
        32 test_main       test_pkt_access test_pkt_access
        33 test_subprog1   test_pkt_access_subprog1 test_pkt_access
        34 test_subprog2   test_pkt_access_subprog2 test_pkt_access
        35 test_subprog3   test_pkt_access_subprog3 test_pkt_access
        36 new_get_skb_len get_skb_len test_pkt_access
        37 new_get_skb_ifindex get_skb_ifindex test_pkt_access
        38 new_get_constant get_constant test_pkt_access
      
      The BPF program dump_bpf_prog() in iterators.bpf.c is printing this data about
      all BPF programs currently loaded in the system. This information is unstable
      and will change from kernel to kernel as ".debug" suffix conveys.
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20200819042759.51280-4-alexei.starovoitov@gmail.com
      d71fa5c9
  12. Aug 07, 2020
  13. Aug 05, 2020
  14. Aug 04, 2020
    • Masami Hiramatsu's avatar
      bootconfig: Fix to find the initargs correctly · 477d0847
      Masami Hiramatsu authored
      Since the parse_args() stops parsing at '--', bootconfig_params()
      will never get the '--' as param and initargs_found never be true.
      In the result, if we pass some init arguments via the bootconfig,
      those are always appended to the kernel command line with '--'
      even if the kernel command line already has '--'.
      
      To fix this correctly, check the return value of parse_args()
      and set initargs_found true if the return value is not an error
      but a valid address.
      
      Link: https://lkml.kernel.org/r/159650953285.270383.14822353843556363851.stgit@devnote2
      
      
      
      Fixes: f61872bb ("bootconfig: Use parse_args() to find bootconfig and '--'")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Suggested-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      477d0847
    • Stafford Horne's avatar
      init: Align init_task to avoid conflict with MUTEX_FLAGS · d0b7213f
      Stafford Horne authored
      
      When booting on 32-bit machines (seen on OpenRISC) I saw this warning
      with CONFIG_DEBUG_MUTEXES turned on.
      
          ------------[ cut here ]------------
          WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:1242 __mutex_unlock_slowpath+0x328/0x3ec
          DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
          Modules linked in:
          CPU: 0 PID: 0 Comm: swapper Not tainted 5.8.0-rc1-simple-smp-00005-g2864e2171db4-dirty #179
          Call trace:
          [<(ptrval)>] dump_stack+0x34/0x48
          [<(ptrval)>] __warn+0x104/0x158
          [<(ptrval)>] ? __mutex_unlock_slowpath+0x328/0x3ec
          [<(ptrval)>] warn_slowpath_fmt+0x7c/0x94
          [<(ptrval)>] __mutex_unlock_slowpath+0x328/0x3ec
          [<(ptrval)>] mutex_unlock+0x18/0x28
          [<(ptrval)>] __cpuhp_setup_state_cpuslocked.part.0+0x29c/0x2f4
          [<(ptrval)>] ? page_alloc_cpu_dead+0x0/0x30
          [<(ptrval)>] ? start_kernel+0x0/0x684
          [<(ptrval)>] __cpuhp_setup_state+0x4c/0x5c
          [<(ptrval)>] page_alloc_init+0x34/0x68
          [<(ptrval)>] ? start_kernel+0x1a0/0x684
          [<(ptrval)>] ? early_init_dt_scan_nodes+0x60/0x70
          irq event stamp: 0
      
      I traced this to kernel/locking/mutex.c storing 3 bits of MUTEX_FLAGS in
      the task_struct pointer (mutex.owner).  There is a comment saying that
      task_structs are always aligned to L1_CACHE_BYTES.  This is not true for
      the init_task.
      
      On 64-bit machines this is not a problem because symbol addresses are
      naturally aligned to 64-bits providing 3 bits for MUTEX_FLAGS.  Howerver,
      for 32-bit machines the symbol address only has 2 bits available.
      
      Fix this by setting init_task alignment to at least L1_CACHE_BYTES.
      
      Signed-off-by: default avatarStafford Horne <shorne@gmail.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      d0b7213f
  15. Jul 31, 2020
  16. Jul 30, 2020
Loading