1. 20 Sep, 2022 1 commit
    • Hou Tao's avatar
      bpf: Check whether or not node is NULL before free it in free_bulk · c31b38cb
      Hou Tao authored
      llnode could be NULL if there are new allocations after the checking of
      c-free_cnt > c->high_watermark in bpf_mem_refill() and before the
      calling of __llist_del_first() in free_bulk (e.g. a PREEMPT_RT kernel
      or allocation in NMI context). And it will incur oops as shown below:
      
       BUG: kernel NULL pointer dereference, address: 0000000000000000
       #PF: supervisor write access in kernel mode
       #PF: error_code(0x0002) - not-present page
       PGD 0 P4D 0
       Oops: 0002 [#1] PREEMPT_RT SMP
       CPU: 39 PID: 373 Comm: irq_work/39 Tainted: G        W          6.0.0-rc6-rt9+ #1
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
       RIP: 0010:bpf_mem_refill+0x66/0x130
       ......
       Call Trace:
        <TASK>
        irq_work_single+0x24/0x60
        irq_work_run_list+0x24/0x30
        run_irq_workd+0x18/0x20
        smpboot_thread_fn+0x13f/0x2c0
        kthread+0x121/0x140
        ? kthread_complete_and_exit+0x20/0x20
        ret_from_fork+0x1f/0x30
        </TASK>
      
      Simply fixing it by checking whether or not llnode is NULL in free_bulk().
      
      Fixes: 8d5a8011 ("bpf: Batch call_rcu callbacks instead of SLAB_TYPESAFE_BY_RCU.")
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Link: https://lore.kernel.org/r/20220919144811.3570825-1-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c31b38cb
  2. 19 Sep, 2022 1 commit
  3. 17 Sep, 2022 1 commit
  4. 16 Sep, 2022 8 commits
  5. 15 Sep, 2022 1 commit
    • Dave Marchevsky's avatar
      bpf: Add verifier check for BPF_PTR_POISON retval and arg · 47e34cb7
      Dave Marchevsky authored
      BPF_PTR_POISON was added in commit c0a5a21c ("bpf: Allow storing
      referenced kptr in map") to denote a bpf_func_proto btf_id which the
      verifier will replace with a dynamically-determined btf_id at verification
      time.
      
      This patch adds verifier 'poison' functionality to BPF_PTR_POISON in
      order to prepare for expanded use of the value to poison ret- and
      arg-btf_id in ongoing work, namely rbtree and linked list patchsets
      [0, 1]. Specifically, when the verifier checks helper calls, it assumes
      that BPF_PTR_POISON'ed ret type will be replaced with a valid type before
      - or in lieu of - the default ret_btf_id logic. Similarly for arg btf_id.
      
      If poisoned btf_id reaches default handling block for either, consider
      this a verifier internal error and fail verification. Otherwise a helper
      w/ poisoned btf_id but no verifier logic replacing the type will cause a
      crash as the invalid pointer is dereferenced.
      
      Also move BPF_PTR_POISON to existing include/linux/posion.h header and
      remove unnecessary shift.
      
        [0]: lore.kernel.org/bpf/20220830172759.4069786-1-davemarchevsky@fb.com
        [1]: lore.kernel.org/bpf/20220904204145.3089-1-memxor@gmail.com
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Acked-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Link: https://lore.kernel.org/r/20220912154544.1398199-1-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      47e34cb7
  6. 11 Sep, 2022 9 commits
  7. 10 Sep, 2022 2 commits
  8. 09 Sep, 2022 5 commits
  9. 07 Sep, 2022 12 commits