All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] kprobes: permit use without modules
@ 2024-03-26 16:36 ` Mark Rutland
  0 siblings, 0 replies; 32+ messages in thread
From: Mark Rutland @ 2024-03-26 16:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: agordeev, anil.s.keshavamurthy, aou, bp, catalin.marinas,
	dave.hansen, davem, gor, hca, jarkko, jcalvinowens,
	linux-arm-kernel, mark.rutland, mhiramat, mingo, mpe,
	naveen.n.rao, palmer, paul.walmsley, tglx, 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.

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                   | 34 ++++++++++++++++++++----------
 kernel/trace/trace_kprobe.c        | 15 +++++++++++--
 16 files changed, 87 insertions(+), 34 deletions(-)

-- 
2.30.2


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

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

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 16:36 [PATCH 0/4] kprobes: permit use without modules Mark Rutland
2024-03-26 16:36 ` Mark Rutland
2024-03-26 16:36 ` [PATCH 1/4] arm64: patching: always use fixmap Mark Rutland
2024-03-26 16:36   ` Mark Rutland
2024-03-26 16:36 ` [PATCH 2/4] kprobes/treewide: Add kprobes_ prefix to insn alloc/free functions Mark Rutland
2024-03-26 16:36   ` Mark Rutland
2024-03-26 17:11   ` Jarkko Sakkinen
2024-03-26 17:11     ` Jarkko Sakkinen
2024-03-26 16:36 ` [PATCH 3/4] kprobes/treewide: Explicitly override " Mark Rutland
2024-03-26 16:36   ` Mark Rutland
2024-04-13  7:22   ` Alexander Gordeev
2024-04-13  7:22     ` Alexander Gordeev
2024-03-26 16:36 ` [PATCH 4/4] kprobes: Remove core dependency on modules Mark Rutland
2024-03-26 16:36   ` Mark Rutland
2024-03-26 17:13   ` Jarkko Sakkinen
2024-03-26 17:13     ` Jarkko Sakkinen
2024-03-26 17:38     ` Mark Rutland
2024-03-26 17:38       ` Mark Rutland
2024-03-27  0:01       ` Masami Hiramatsu
2024-03-27  0:01         ` Masami Hiramatsu
2024-03-27 13:23         ` Jarkko Sakkinen
2024-03-27 13:23           ` Jarkko Sakkinen
2024-03-27 17:46         ` Jarkko Sakkinen
2024-03-27 17:46           ` Jarkko Sakkinen
2024-03-27 23:47           ` Masami Hiramatsu
2024-03-27 23:47             ` Masami Hiramatsu
2024-03-30 11:32             ` Jarkko Sakkinen
2024-03-30 11:32               ` Jarkko Sakkinen
2024-04-03 11:20   ` Mark Rutland
2024-04-03 11:20     ` Mark Rutland
2024-04-03 16:10     ` Jarkko Sakkinen
2024-04-03 16:10       ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.