linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] riscv: Fix Fix set_memory_XX() and set_direct_map_XX()
@ 2023-10-06  9:29 Alexandre Ghiti
  2023-10-06  9:29 ` [PATCH 1/2] riscv: Don't use PGD entries for the linear mapping Alexandre Ghiti
  2023-10-06  9:29 ` [PATCH 2/2] riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge linear mappings Alexandre Ghiti
  0 siblings, 2 replies; 5+ messages in thread
From: Alexandre Ghiti @ 2023-10-06  9:29 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Mike Rapoport,
	linux-mm, linux-riscv, linux-kernel
  Cc: Alexandre Ghiti

Those 2 patches fix the set_memory_XX() and set_direct_map_XX() APIs, which
in turn fix STRICT_KERNEL_RWX and memfd_secret(). Those were broken since the
permission changes were not applied to the linear mapping because the linear
mapping is mapped using hugepages and walk_page_range_novma() does not split
such mappings.

To fix that, patch 1 disables PGD mappings in the linear mapping as it is
hard to propagate changes at this level in *all* the page tables, this has the
downside of disabling PMD mapping for sv32 and PUD (1GB) mapping for sv39 in
the linear mapping (for specific kernels, we could add a Kconfig to enable
ARCH_HAS_SET_DIRECT_MAP and STRICT_KERNEL_RWX if needed, I'm pretty sure we'll
discuss that).

patch 2 implements the split of the huge linear mappings so that
walk_page_range_novma() can properly apply the permissions. The whole split is
protected with mmap_sem in write mode, but I'm wondering if that's enough,
any opinion on that is appreciated.

Alexandre Ghiti (2):
  riscv: Don't use PGD entries for the linear mapping
  riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge
    linear mappings

 arch/riscv/mm/init.c     |  12 +-
 arch/riscv/mm/pageattr.c | 263 ++++++++++++++++++++++++++++++++-------
 2 files changed, 227 insertions(+), 48 deletions(-)

-- 
2.39.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-07  2:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06  9:29 [PATCH 0/2] riscv: Fix Fix set_memory_XX() and set_direct_map_XX() Alexandre Ghiti
2023-10-06  9:29 ` [PATCH 1/2] riscv: Don't use PGD entries for the linear mapping Alexandre Ghiti
2023-10-06  9:29 ` [PATCH 2/2] riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge linear mappings Alexandre Ghiti
2023-10-06 23:40   ` kernel test robot
2023-10-07  2:38   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox