1. 09 Mar, 2021 1 commit
    • Ritesh Harjani's avatar
      iomap: Fix negative assignment to unsigned sis->pages in iomap_swapfile_activate · 5808fecc
      Ritesh Harjani authored
      In case if isi.nr_pages is 0, we are making sis->pages (which is
      unsigned int) a huge value in iomap_swapfile_activate() by assigning -1.
      This could cause a kernel crash in kernel v4.18 (with below signature).
      Or could lead to unknown issues on latest kernel if the fake big swap gets
      used.
      
      Fix this issue by returning -EINVAL in case of nr_pages is 0, since it
      is anyway a invalid swapfile. Looks like this issue will be hit when
      we have pagesize < blocksize type of configuration.
      
      I was able to hit the issue in case of a tiny swap file with below
      test script.
      https://raw.githubusercontent.com/riteshharjani/LinuxStudy/master/scripts/swap-issue.sh
      
      kernel crash analysis on v4.18
      ==============================
      On v4.18 kernel, it causes a kernel panic, since sis->pages becomes
      a huge value and isi.nr_extents is 0. When 0 is returned it is
      considered as a swapfile over NFS and SWP_FILE is set (sis->flags |= SWP_FILE).
      Then when swapoff was getting called it was calling a_ops->swap_deactivate()
      if (sis->flags & SWP_FILE) is true. Since a_ops->swap_deactivate() is
      NULL in case of XFS, it causes below panic.
      
      Panic signature on v4.18 kernel:
      =======================================
      root@qemu:/home/qemu# [ 8291.723351] XFS (loop2): Unmounting Filesystem
      [ 8292.123104] XFS (loop2): Mounting V5 Filesystem
      [ 8292.132451] XFS (loop2): Ending clean mount
      [ 8292.263362] Adding 4294967232k swap on /mnt1/test/swapfile.  Priority:-2 extents:1 across:274877906880k
      [ 8292.277834] Unable to handle kernel paging request for instruction fetch
      [ 8292.278677] Faulting instruction address: 0x00000000
      cpu 0x19: Vector: 400 (Instruction Access) at [c0000009dd5b7ad0]
          pc: 0000000000000000
          lr: c0000000003eb9dc: destroy_swap_extents+0xfc/0x120
          sp: c0000009dd5b7d50
         msr: 8000000040009033
        current = 0xc0000009b6710080
        paca    = 0xc00000003ffcb280   irqmask: 0x03   irq_happened: 0x01
          pid   = 5604, comm = swapoff
      Linux version 4.18.0 (riteshh@xxxxxxx) (gcc version 8.4.0 (Ubuntu 8.4.0-1ubuntu1~18.04)) #57 SMP Wed Mar 3 01:33:04 CST 2021
      enter ? for help
      [link register   ] c0000000003eb9dc destroy_swap_extents+0xfc/0x120
      [c0000009dd5b7d50] c0000000025a7058 proc_poll_event+0x0/0x4 (unreliable)
      [c0000009dd5b7da0] c0000000003f0498 sys_swapoff+0x3f8/0x910
      [c0000009dd5b7e30] c00000000000bbe4 system_call+0x5c/0x70
      Exception: c01 (System Call) at 00007ffff7d208d8
      Signed-off-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      [djwong: rework the comment to provide more details]
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      5808fecc
  2. 06 Mar, 2021 4 commits
  3. 05 Mar, 2021 33 commits
  4. 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