linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Implement STRICT_MODULE_RWX for powerpc
@ 2019-10-04  7:50 Russell Currey
  2019-10-04  7:50 ` [PATCH v3 1/4] powerpc/mm: Implement set_memory() routines Russell Currey
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Russell Currey @ 2019-10-04  7:50 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: ajd, npiggin, joel, Russell Currey, rashmica.g, dja

It's been quite a while since the last iteration, there were a few
things to hunt down and fix.

The first was the way that I was updating PTEs was using set_pte_at()
unsafely - now, each page is updated by clearing -> flushing -> setting.
This should be generic across all MMUs, I know that there are some
potential inefficiencies - for example, Hash flushes the entire PID
regardless of the given page range - but I don't think it's a very big
deal.

The next was that there is an errant page that was tricky to hunt down,
it turned out to be that kprobes never get marked RO after creation,    
leading to (at least) one W+X page present in the kernel, even with both
STRICT_KERNEL_RWX and STRICT_MODULE_RWX on.

I added a debugfs handler to call ptdump_check_wx() to facilitate making
sure module RWX continues to work after boot.

There's more detail in the final patch about exactly how "on by default"
module RWX is, but it doesn't really matter until STRICT_KERNEL_RWX is  
on by default too.

Thanks to Nick Piggin, Michael Ellerman, Daniel Axtens, and others for  
helping.

Christophe, I did test this in qemu mac99 so hopefully it works for all
32bit, I'm sure you'll let me know if it doesn't.

Would appreciate an ack from Joel to enable this in skiroot_defconfig.

Russell Currey (4):
  powerpc/mm: Implement set_memory() routines
  powerpc/kprobes: Mark newly allocated probes as RO
  powerpc/mm/ptdump: debugfs handler for W+X checks at runtime
  powerpc: Enable STRICT_MODULE_RWX

 arch/powerpc/Kconfig                   |  2 +
 arch/powerpc/configs/skiroot_defconfig |  1 +
 arch/powerpc/include/asm/set_memory.h  | 32 ++++++++++++++
 arch/powerpc/kernel/kprobes.c          |  3 ++
 arch/powerpc/mm/Makefile               |  1 +
 arch/powerpc/mm/pageattr.c             | 60 ++++++++++++++++++++++++++
 arch/powerpc/mm/ptdump/ptdump.c        | 31 ++++++++++---
 7 files changed, 124 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/include/asm/set_memory.h
 create mode 100644 arch/powerpc/mm/pageattr.c

-- 
2.23.0


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

end of thread, other threads:[~2019-10-23  2:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04  7:50 [PATCH v3 0/4] Implement STRICT_MODULE_RWX for powerpc Russell Currey
2019-10-04  7:50 ` [PATCH v3 1/4] powerpc/mm: Implement set_memory() routines Russell Currey
2019-10-23  2:56   ` Michael Ellerman
2019-10-04  7:50 ` [PATCH v3 2/4] powerpc/kprobes: Mark newly allocated probes as RO Russell Currey
2019-10-14  2:22   ` Andrew Donnellan
2019-10-04  7:50 ` [PATCH v3 3/4] powerpc/mm/ptdump: debugfs handler for W+X checks at runtime Russell Currey
2019-10-08  1:59   ` Daniel Axtens
2019-10-08  6:21   ` Christophe Leroy
2019-10-14  2:36     ` Russell Currey
2019-10-04  7:50 ` [PATCH v3 4/4] powerpc: Enable STRICT_MODULE_RWX Russell Currey
2019-10-10 13:13   ` Daniel Axtens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).