]> Git Repo - linux.git/commitdiff
Merge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <[email protected]>
Sun, 5 Mar 2023 19:07:58 +0000 (11:07 -0800)
committerLinus Torvalds <[email protected]>
Sun, 5 Mar 2023 19:07:58 +0000 (11:07 -0800)
Pull VM_FAULT_RETRY fixes from Al Viro:
 "Some of the page fault handlers do not deal with the following case
  correctly:

   - handle_mm_fault() has returned VM_FAULT_RETRY

   - there is a pending fatal signal

   - fault had happened in kernel mode

  Correct action in such case is not "return unconditionally" - fatal
  signals are handled only upon return to userland and something like
  copy_to_user() would end up retrying the faulting instruction and
  triggering the same fault again and again.

  What we need to do in such case is to make the caller to treat that as
  failed uaccess attempt - handle exception if there is an exception
  handler for faulting instruction or oops if there isn't one.

  Over the years some architectures had been fixed and now are handling
  that case properly; some still do not. This series should fix the
  remaining ones.

  Status:

   - m68k, riscv, hexagon, parisc: tested/acked by maintainers.

   - alpha, sparc32, sparc64: tested locally - bug has been reproduced
     on the unpatched kernel and verified to be fixed by this series.

   - ia64, microblaze, nios2, openrisc: build, but otherwise completely
     untested"

* tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  openrisc: fix livelock in uaccess
  nios2: fix livelock in uaccess
  microblaze: fix livelock in uaccess
  ia64: fix livelock in uaccess
  sparc: fix livelock in uaccess
  alpha: fix livelock in uaccess
  parisc: fix livelock in uaccess
  hexagon: fix livelock in uaccess
  riscv: fix livelock in uaccess
  m68k: fix livelock in uaccess

1  2 
arch/riscv/mm/fault.c

diff --combined arch/riscv/mm/fault.c
index eb0774d9c03b1539254adbe3e692c63c2e850ab6,c91d85349d39a3e8c36ba1fd7064e94637402d8e..460f785f6e09cd8fb1441f2fff49288f5256181e
@@@ -267,12 -267,10 +267,12 @@@ asmlinkage void do_page_fault(struct pt
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
  
 -      if (!user_mode(regs) && addr < TASK_SIZE &&
 -                      unlikely(!(regs->status & SR_SUM)))
 -              die_kernel_fault("access to user memory without uaccess routines",
 -                              addr, regs);
 +      if (!user_mode(regs) && addr < TASK_SIZE && unlikely(!(regs->status & SR_SUM))) {
 +              if (fixup_exception(regs))
 +                      return;
 +
 +              die_kernel_fault("access to user memory without uaccess routines", addr, regs);
 +      }
  
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
  
@@@ -326,8 -324,11 +326,11 @@@ good_area
         * signal first. We do not need to release the mmap_lock because it
         * would already be released in __lock_page_or_retry in mm/filemap.c.
         */
-       if (fault_signal_pending(fault, regs))
+       if (fault_signal_pending(fault, regs)) {
+               if (!user_mode(regs))
+                       no_context(regs, addr);
                return;
+       }
  
        /* The fault is fully completed (including releasing mmap lock) */
        if (fault & VM_FAULT_COMPLETED)
This page took 0.066317 seconds and 4 git commands to generate.