Skip to content

kprobes: Support probing __init and __exit functions in modules

Masami Hiramatsu lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7module: Add within_module_core() and within_module_init()include/linux/module.h kernel/module.c+22 -151 reply
2/7kprobes: Add kprobe_insn_mutex and cleanup arch_remove_kprobe()arch/arm/kernel/kprobes.c arch/ia64/kernel/kprobes.c arch/powerpc/kernel/kprobes.c +4 more+38 -193 replies
3/7kprobes: Add __kprobes to kprobe internal functionskernel/kprobes.c+9 -71 reply
4/7kprobes: Support probing module __exit functionDocumentation/kprobes.txt include/linux/kprobes.h kernel/kprobes.c+123 -363 replies
5/7kprobes: Remove called_from argumentkernel/kprobes.c+14 -563 replies
6/7module: Add MODULE_STATE_LIVE notifykernel/module.c+2 -01 reply
7/7kprobes: Support probing module __init functionkernel/kprobes.c+19 -41 reply

Reviews trailers per patch

5 of 7 patches have a Reviewed-by or Acked-by.

PatchMasami HiramatsuAnanth N Mavinakayanahalli
1/7
2/7A-b
3/7A-b
4/7A-b
5/7A-b A-b
6/7
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] kprobes: Support probing __init and __exit functions in modules

Hi,

This series of patches allows kprobes to probe module's __init and __exit functions. This means, you can probe driver initialization and terminating.

Currently, kprobes can't probe __init function because these functions are freed after module initialization. And it also can't probe module __exit functions because kprobe increments reference count of target module and user can't unload it. this means __exit functions never be called unless removing probes from the module.

To solve both cases, this series of patches introduces GONE flag and sets it when the target code is freed(for this purpose, kprobes hooks MODULE_STATE_* events). This also removes refcount incrementing for allowing user to unload target module. Users can check which probes are GONE by debugfs interface. For taking timing of freeing module's .init text, these also include a patch which adds module's notifier of MODULE_STATE_LIVE event.

This series of patches can be applied after applying below patches on 2.6.28-rc4.

http://lkml.org/lkml/2008/11/6/236
http://lkml.org/lkml/2008/11/5/346

Thank you,

 Documentation/kprobes.txt     |    5
 arch/arm/kernel/kprobes.c     |    2
 arch/ia64/kernel/kprobes.c    |    8 -
 arch/powerpc/kernel/kprobes.c |    7 -
 arch/s390/kernel/kprobes.c    |    7 -
 arch/x86/kernel/kprobes.c     |    7 -
 include/linux/kprobes.h       |   15 +-
 include/linux/module.h        |   12 +
 kernel/kprobes.c              |  260 ++++++++++++++++++++++++++----------------
 kernel/module.c               |   27 +---
 10 files changed, 220 insertions(+), 130 deletions(-)
Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected]