1. 06 Mar, 2021 5 commits
    • Jens Axboe's avatar
      io-wq: fix race in freeing 'wq' and worker access · 886d0137
      Jens Axboe authored
      Ran into a use-after-free on the main io-wq struct, wq. It has a worker
      ref and completion event, but the manager itself isn't holding a
      reference. This can lead to a race where the manager thinks there are
      no workers and exits, but a worker is being added. That leads to the
      following trace:
      
      BUG: KASAN: use-after-free in io_wqe_worker+0x4c0/0x5e0
      Read of size 8 at addr ffff888108baa8a0 by task iou-wrk-3080422/3080425
      
      CPU: 5 PID: 3080425 Comm: iou-wrk-3080422 Not tainted 5.12.0-rc1+ #110
      Hardware name: Micro-Star International Co., Ltd. MS-7C60/TRX40 PRO 10G (MS-7C60), BIOS 1.60 05/13/2020
      Call Trace:
       dump_stack+0x90/0xbe
       print_address_description.constprop.0+0x67/0x28d
       ? io_wqe_worker+0x4c0/0x5e0
       kasan_report.cold+0x7b/0xd4
       ? io_wqe_worker+0x4c0/0x5e0
       __asan_load8+0x6d/0xa0
       io_wqe_worker+0x4c0/0x5e0
       ? io_worker_handle_work+0xc00/0xc00
       ? recalc_sigpending+0xe5/0x120
       ? io_worker_handle_work+0xc00/0xc00
       ? io_worker_handle_work+0xc00/0xc00
       ret_from_fork+0x1f/0x30
      
      Allocated by task 3080422:
       kasan_save_stack+0x23/0x60
       __kasan_kmalloc+0x80/0xa0
       kmem_cache_alloc_node_trace+0xa0/0x480
       io_wq_create+0x3b5/0x600
       io_uring_alloc_task_context+0x13c/0x380
       io_uring_add_task_file+0x109/0x140
       __x64_sys_io_uring_enter+0x45f/0x660
       do_syscall_64+0x32/0x80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Freed by task 3080422:
       kasan_save_stack+0x23/0x60
       kasan_set_track+0x20/0x40
       kasan_set_free_info+0x24/0x40
       __kasan_slab_free+0xe8/0x120
       kfree+0xa8/0x400
       io_wq_put+0x14a/0x220
       io_wq_put_and_exit+0x9a/0xc0
       io_uring_clean_tctx+0x101/0x140
       __io_uring_files_cancel+0x36e/0x3c0
       do_exit+0x169/0x1340
       __x64_sys_exit+0x34/0x40
       do_syscall_64+0x32/0x80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Have the manager itself hold a reference, and now both drop points drop
      and complete if we hit zero, and the manager can unconditionally do a
      wait_for_completion() instead of having a race between reading the ref
      count and waiting if it was non-zero.
      
      Fixes: fb3a1f6c ("io-wq: have manager wait for all workers to exit")
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      886d0137
    • Linus Torvalds's avatar
      Linux 5.12-rc2 · a38fd874
      Linus Torvalds authored
      a38fd874
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · f3ed4de6
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Nothing special here, though Bob's regression fixes for rxe would have
        made it before the rc cycle had there not been such strong winter
        weather!
      
         - Fix corner cases in the rxe reference counting cleanup that are
           causing regressions in blktests for SRP
      
         - Two kdoc fixes so W=1 is clean
      
         - Missing error return in error unwind for mlx5
      
         - Wrong lock type nesting in IB CM"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/rxe: Fix errant WARN_ONCE in rxe_completer()
        RDMA/rxe: Fix extra deref in rxe_rcv_mcast_pkt()
        RDMA/rxe: Fix missed IB reference counting in loopback
        RDMA/uverbs: Fix kernel-doc warning of _uverbs_alloc
        RDMA/mlx5: Set correct kernel-doc identifier
        IB/mlx5: Add missing error code
        RDMA/rxe: Fix missing kconfig dependency on CRYPTO
        RDMA/cm: Fix IRQ restore in ib_send_cm_sidr_rep
      f3ed4de6
    • Linus Torvalds's avatar
      Merge tag 'gcc-plugins-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · de5bd6c5
      Linus Torvalds authored
      Pull gcc-plugins fixes from Kees Cook:
       "Tiny gcc-plugin fixes for v5.12-rc2. These issues are small but have
        been reported a couple times now by static analyzers, so best to get
        them fixed to reduce the noise. :)
      
         - Fix coding style issues (Jason Yan)"
      
      * tag 'gcc-plugins-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        gcc-plugins: latent_entropy: remove unneeded semicolon
        gcc-plugins: structleak: remove unneeded variable 'ret'
      de5bd6c5
    • Linus Torvalds's avatar
      Merge tag 'pstore-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 8b24ef44
      Linus Torvalds authored
      Pull pstore fixes from Kees Cook:
      
       - Rate-limit ECC warnings (Dmitry Osipenko)
      
       - Fix error path check for NULL (Tetsuo Handa)
      
      * tag 'pstore-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        pstore/ram: Rate-limit "uncorrectable error in header" message
        pstore: Fix warning in pstore_kill_sb()
      8b24ef44
  2. 05 Mar, 2021 33 commits
  3. 04 Mar, 2021 2 commits
    • Jens Axboe's avatar
      kernel: provide create_io_thread() helper · cc440e87
      Jens Axboe authored
      Provide a generic helper for setting up an io_uring worker. Returns a
      task_struct so that the caller can do whatever setup is needed, then call
      wake_up_new_task() to kick it into gear.
      
      Add a kernel_clone_args member, io_thread, which tells copy_process() to
      mark the task with PF_IO_WORKER.
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      cc440e87
    • Pavel Begunkov's avatar
      io_uring: reliably cancel linked timeouts · dd59a3d5
      Pavel Begunkov authored
      Linked timeouts are fired asynchronously (i.e. soft-irq), and use
      generic cancellation paths to do its stuff, including poking into io-wq.
      The problem is that it's racy to access tctx->io_wq, as
      io_uring_task_cancel() and others may be happening at this exact moment.
      Mark linked timeouts with REQ_F_INLIFGHT for now, making sure there are
      no timeouts before io-wq destraction.
      Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      dd59a3d5