linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] kprobes: permit use without modules
@ 2024-04-03 15:01 Mark Rutland
  2024-04-03 15:01 ` [PATCH v2 1/4] arm64: patching: always use fixmap Mark Rutland
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Mark Rutland @ 2024-04-03 15:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: anil.s.keshavamurthy, aou, catalin.marinas, davem, jarkko,
	linux-arm-kernel, mark.rutland, mhiramat, naveen.n.rao, palmer,
	paul.walmsley, will

Currently KPROBES depends on MODULES and cannot be built when support
for modules is not enabled. This is largely an artifact of the
default/generic code for allocating insn pages using module_alloc(),
though several architectures do not use this and have no strict
dependency on MODULES. It would be nice to allow KPROBES to be used
without MODULES, as this can be useful for testing and/or in certain
constrained environments.

This series (based on v6.9-rc1) removes the artificial dependency on
MODULES. This permits (but does not require) that architectures which
don't use module_alloc() to allocate kprobe insn pages can support
kprobes when module support is not enabled.

The series deliberately avoids adding a common text allocator, as the
requirements for allocating kprobe memory van vary by architecture, and
can differ from other text allocations. However, architectures can
easily call a common allocator if they wish, and this series does not
preclude using common allocators immediately or in future.

The key change is in patch 3. This requires that architectures which
provide their own alloc function must provide the corresponding free
function and select HAVE_KPROBES_ALLOC with any appropriate dependencies
for their implementation. Architectures which use the generic functions
are left as-is with a dependency on MODULES.

The final patch allows the core kprobes code to be built without
MODULES, and removes the explicit dependency from Kconfig. This is
derived from Jarkko's recent v6 attempt:

  https://lore.kernel.org/lkml/20240326012102.27438-1-jarkko@kernel.org/
 
With the series applied, arm64 and riscv can enable KPROBES without
MODULES, while powerpc/s390/x86 are still depend on MODULES as their
alloc functions currently use module_alloc(), and all other
architectures with KPROBES uses the generic implementation that depends
on MODULES. I believe it should be relatively easy to enable
powerpc/s390/x86 to not depend on MODULES.

Since v1 [1]:
* Rebase to v6.9-rc2 (trivial)
* Update to Jarkko's v7 cleanups for core kprobes
* Fix accidental use of KPROBES_USE_MODULE_ALLOC
* Improve commit messages
* Update Cc lists

[1] https://lore.kernel.org/lkml/20240326163624.3253157-1-mark.rutland@arm.com/

Mark.

Jarkko Sakkinen (1):
  kprobes: Remove core dependency on modules

Mark Rutland (3):
  arm64: patching: always use fixmap
  kprobes/treewide: Add kprobes_ prefix to insn alloc/free functions
  kprobes/treewide: Explicitly override alloc/free functions

 arch/Kconfig                       |  5 ++-
 arch/arm64/Kconfig                 |  1 +
 arch/arm64/kernel/patching.c       | 10 ++---
 arch/arm64/kernel/probes/kprobes.c |  7 ++-
 arch/powerpc/Kconfig               |  3 +-
 arch/powerpc/kernel/kprobes.c      |  7 ++-
 arch/powerpc/kernel/optprobes.c    |  4 +-
 arch/riscv/Kconfig                 |  1 +
 arch/riscv/kernel/probes/kprobes.c |  7 ++-
 arch/s390/Kconfig                  |  3 +-
 arch/s390/kernel/kprobes.c         |  7 ++-
 arch/x86/Kconfig                   |  3 +-
 arch/x86/kernel/kprobes/core.c     |  7 ++-
 include/linux/kprobes.h            |  7 +--
 kernel/kprobes.c                   | 68 +++++++++++++++++-------------
 kernel/trace/trace_kprobe.c        | 15 ++++++-
 16 files changed, 103 insertions(+), 52 deletions(-)

-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-04-13 20:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03 15:01 [PATCH v2 0/4] kprobes: permit use without modules Mark Rutland
2024-04-03 15:01 ` [PATCH v2 1/4] arm64: patching: always use fixmap Mark Rutland
2024-04-03 16:20   ` Jarkko Sakkinen
2024-04-03 16:51     ` Mark Rutland
2024-04-04 14:48       ` Jarkko Sakkinen
2024-04-03 17:52   ` Catalin Marinas
2024-04-03 23:44     ` Masami Hiramatsu
2024-04-03 15:01 ` [PATCH v2 2/4] kprobes/treewide: Add kprobes_ prefix to insn alloc/free functions Mark Rutland
2024-04-03 16:39   ` Jarkko Sakkinen
2024-04-03 15:01 ` [PATCH v2 3/4] kprobes/treewide: Explicitly override " Mark Rutland
2024-04-03 16:40   ` Jarkko Sakkinen
2024-04-03 15:01 ` [PATCH v2 4/4] kprobes: Remove core dependency on modules Mark Rutland
2024-04-03 16:41   ` Jarkko Sakkinen
2024-04-04  8:15   ` Jarkko Sakkinen
2024-04-04 15:18     ` Jarkko Sakkinen
2024-04-04 16:10       ` Masami Hiramatsu
2024-04-04 16:47         ` Mark Rutland
2024-04-05  3:13           ` Masami Hiramatsu
2024-04-13 20:16           ` Jarkko Sakkinen
2024-04-11 22:54         ` Jarkko Sakkinen

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).