[PATCH 0/2] Remove incorrect host mincore call and add rodata handling

Benjamin Berg benjamin at sipsolutions.net
Mon Feb 10 08:09:24 PST 2025


From: Benjamin Berg <benjamin.berg at intel.com>

Hi,

using mincore() to check whether a page is owned by UML is not correct
as it returns whether the page is resident in memory and not whether
something has been mapped at the address. This means that UML could get
spurious failures in *_nofault functions like copy_from_kernel_nofault).

If this happens, it can create hard to debug issues. For us the problem
showed up because hostfs was randomly throwing ENOENT errors when
loading libraries (including ld.so). This can be traced back to
dentry_path_raw failing as it uses an optimization that requires the
use of copy_from_kernel_nofault internally (see the documentation of
prepend_name and prepend_copy).

Pull in the existing RODATA patch from Johannes (with light editing) and
then remove the call to mincore() as it is incorrect.

Benjamin

Benjamin Berg (1):
  um: remove copy_from_kernel_nofault_allowed

Johannes Berg (1):
  um: mark rodata read-only and implement _nofault accesses

 arch/um/Kconfig                          |  1 +
 arch/um/include/asm/processor-generic.h  |  2 +
 arch/um/include/asm/uaccess.h            | 20 +++++++---
 arch/um/include/shared/arch.h            |  2 +
 arch/um/include/shared/as-layout.h       |  2 +-
 arch/um/include/shared/irq_user.h        |  3 +-
 arch/um/include/shared/kern_util.h       | 12 ++++--
 arch/um/include/shared/os.h              |  1 -
 arch/um/kernel/Makefile                  |  2 +-
 arch/um/kernel/irq.c                     |  3 +-
 arch/um/kernel/maccess.c                 | 19 ---------
 arch/um/kernel/mem.c                     | 10 +++++
 arch/um/kernel/trap.c                    | 28 ++++++++++---
 arch/um/os-Linux/process.c               | 51 ------------------------
 arch/um/os-Linux/signal.c                |  4 +-
 arch/um/os-Linux/skas/process.c          |  8 ++--
 arch/x86/um/os-Linux/mcontext.c          | 12 ++++++
 arch/x86/um/shared/sysdep/faultinfo_32.h | 12 ++++++
 arch/x86/um/shared/sysdep/faultinfo_64.h | 12 ++++++
 19 files changed, 109 insertions(+), 95 deletions(-)
 delete mode 100644 arch/um/kernel/maccess.c

-- 
2.48.1




More information about the linux-um mailing list