23 Sep, 2010
2 commits
-
Add a jump_label_text_reserved(void *start, void *end), so that other
pieces of code that want to modify kernel text, can first verify that
jump label has not reserved the instruction.Acked-by: Masami Hiramatsu
Signed-off-by: Jason Baron
LKML-Reference:
Signed-off-by: Steven Rostedt -
base patch to implement 'jump labeling'. Based on a new 'asm goto' inline
assembly gcc mechanism, we can now branch to labels from an 'asm goto'
statment. This allows us to create a 'no-op' fastpath, which can subsequently
be patched with a jump to the slowpath code. This is useful for code which
might be rarely used, but which we'd like to be able to call, if needed.
Tracepoints are the current usecase that these are being implemented for.Acked-by: David S. Miller
Signed-off-by: Jason Baron
LKML-Reference:[ cleaned up some formating ]
Signed-off-by: Steven Rostedt
15 Sep, 2010
4 commits
-
This removes following warnings when build with C=1
warning: context imbalance in 'kretprobe_hash_lock' - wrong count at exit
warning: context imbalance in 'kretprobe_table_lock' - wrong count at exit
warning: context imbalance in 'kretprobe_hash_unlock' - unexpected unlock
warning: context imbalance in 'kretprobe_table_unlock' - unexpected unlockSigned-off-by: Namhyung Kim
Acked-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar -
Make following (internal) functions static to make sparse
happier :-)* get_optimized_kprobe: only called from static functions
* kretprobe_table_unlock: _lock function is static
* kprobes_optinsn_template_holder: never called but holding asm codeSigned-off-by: Namhyung Kim
Acked-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar -
Verify jprobe's entry point is a function entry point
using kallsyms' offset value.Signed-off-by: Namhyung Kim
Acked-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar -
Remove call to kernel_text_address() in register_jprobes()
because it is called right after in register_kprobe().Signed-off-by: Namhyung Kim
Acked-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar
09 May, 2010
1 commit
-
Move enable/disable_kprobe() API out from debugfs related code,
because these interfaces are not related to debugfs interface.This fixes a compiler warning.
Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Acked-by: Tony Luck
Cc: systemtap
Cc: DLE
LKML-Reference:
Signed-off-by: Ingo Molnar
11 Mar, 2010
1 commit
-
From : Ananth N Mavinakayanahalli
When freeing the instruction slot, the arithmetic to calculate
the index of the slot in the page needs to account for the total
size of the instruction on the various architectures.Calculate the index correctly when freeing the out-of-line
execution slot.Reported-by: Sachin Sant
Reported-by: Heiko Carstens
Signed-off-by: Ananth N Mavinakayanahalli
Signed-off-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar
26 Feb, 2010
3 commits
-
Add /proc/sys/debug/kprobes-optimization sysctl which enables
and disables kprobes jump optimization on the fly for debugging.Changes in v7:
- Remove ctl_name = CTL_UNNUMBERED for upstream compatibility.Changes in v6:
- Update comments and coding style.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Srikar Dronamraju
Cc: Christoph Hellwig
Cc: Steven Rostedt
Cc: Frederic Weisbecker
Cc: Anders Kaseorg
Cc: Tim Abbott
Cc: Andi Kleen
Cc: Jason Baron
Cc: Mathieu Desnoyers
Cc: Frederic Weisbecker
Cc: Ananth N Mavinakayanahalli
LKML-Reference:
Signed-off-by: Ingo Molnar -
Introduce kprobes jump optimization arch-independent parts.
Kprobes uses breakpoint instruction for interrupting execution
flow, on some architectures, it can be replaced by a jump
instruction and interruption emulation code. This gains kprobs'
performance drastically.To enable this feature, set CONFIG_OPTPROBES=y (default y if the
arch supports OPTPROBE).Changes in v9:
- Fix a bug to optimize probe when enabling.
- Check nearby probes can be optimize/unoptimize when disarming/arming
kprobes, instead of registering/unregistering. This will help
kprobe-tracer because most of probes on it are usually disabled.Changes in v6:
- Cleanup coding style for readability.
- Add comments around get/put_online_cpus().Changes in v5:
- Use get_online_cpus()/put_online_cpus() for avoiding text_mutex
deadlock.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Srikar Dronamraju
Cc: Christoph Hellwig
Cc: Steven Rostedt
Cc: Frederic Weisbecker
Cc: Anders Kaseorg
Cc: Tim Abbott
Cc: Andi Kleen
Cc: Jason Baron
Cc: Mathieu Desnoyers
Cc: Frederic Weisbecker
Cc: Ananth N Mavinakayanahalli
LKML-Reference:
Signed-off-by: Ingo Molnar -
Make insn_slot framework support various size slots.
Current insn_slot just supports one-size instruction buffer
slot. However, kprobes jump optimization needs larger size
buffers.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Srikar Dronamraju
Cc: Christoph Hellwig
Cc: Steven Rostedt
Cc: Frederic Weisbecker
Cc: Anders Kaseorg
Cc: Tim Abbott
Cc: Andi Kleen
Cc: Jason Baron
Cc: Mathieu Desnoyers
Cc: Frederic Weisbecker
Cc: Ananth N Mavinakayanahalli
LKML-Reference:
Signed-off-by: Ingo Molnar
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Srikar Dronamraju
Cc: Christoph Hellwig
Cc: Steven Rostedt
Cc: Frederic Weisbecker
Cc: H. Peter Anvin
Cc: Anders Kaseorg
Cc: Tim Abbott
Cc: Andi Kleen
Cc: Jason Baron
Cc: Mathieu Desnoyers
05 Feb, 2010
1 commit
-
Since mcount function can be called from everywhere,
it should be blacklisted. Moreover, the "mcount" symbol
is a special symbol name. So, it is better to put it in
the generic blacklist.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Ananth N Mavinakayanahalli
Cc: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar
04 Feb, 2010
2 commits
-
Check whether the address of new probe is already reserved by
ftrace or alternatives (on x86) when registering new probe.
If reserved, it returns an error and not register the probe.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Steven Rostedt
Cc: przemyslaw@pawelczyk.it
Cc: Frederic Weisbecker
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Mathieu Desnoyers
Cc: Jason Baron
LKML-Reference:
Signed-off-by: Ingo Molnar -
Disable kprobe booster when CONFIG_PREEMPT=y at this time,
because it can't ensure that all kernel threads preempted on
kprobe's boosted slot run out from the slot even using
freeze_processes().The booster on preemptive kernel will be resumed if
synchronize_tasks() or something like that is introduced.Signed-off-by: Masami Hiramatsu
Cc: systemtap
Cc: DLE
Cc: Ananth N Mavinakayanahalli
Cc: Frederic Weisbecker
Cc: Jim Keniston
Cc: Mathieu Desnoyers
Cc: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar
28 Dec, 2009
1 commit
-
Every time I see this:
kernel/kprobes.c: In function 'register_kretprobe':
kernel/kprobes.c:1038: warning: comparison of distinct pointer types lacks a castI'm wondering if something changed in common code and we need to
do something for s390. Apparently that's not the case.
Let's get rid of this annoying warning.Signed-off-by: Heiko Carstens
Acked-by: Ananth N Mavinakayanahalli
Cc: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar
06 Dec, 2009
1 commit
-
…git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (470 commits)
x86: Fix comments of register/stack access functions
perf tools: Replace %m with %a in sscanf
hw-breakpoints: Keep track of user disabled breakpoints
tracing/syscalls: Make syscall events print callbacks static
tracing: Add DEFINE_EVENT(), DEFINE_SINGLE_EVENT() support to docbook
perf: Don't free perf_mmap_data until work has been done
perf_event: Fix compile error
perf tools: Fix _GNU_SOURCE macro related strndup() build error
trace_syscalls: Remove unused syscall_name_to_nr()
trace_syscalls: Simplify syscall profile
trace_syscalls: Remove duplicate init_enter_##sname()
trace_syscalls: Add syscall_nr field to struct syscall_metadata
trace_syscalls: Remove enter_id exit_id
trace_syscalls: Set event_enter_##sname->data to its metadata
trace_syscalls: Remove unused event_syscall_enter and event_syscall_exit
perf_event: Initialize data.period in perf_swevent_hrtimer()
perf probe: Simplify event naming
perf probe: Add --list option for listing current probe events
perf probe: Add argv_split() from lib/argv_split.c
perf probe: Move probe event utility functions to probe-event.c
...
03 Nov, 2009
1 commit
-
For as long as kretprobes have existed, we've allocated NR_CPUS
instances of kretprobe_instance structures. With the default
value of CONFIG_NR_CPUS increasing on certain architectures, we
are potentially wasting kernel memory.See http://sourceware.org/bugzilla/show_bug.cgi?id=10839#c3 for
more details.Use a saner num_possible_cpus() instead of NR_CPUS for
allocation.Signed-off-by: Ananth N Mavinakayanahalli
Acked-by: Masami Hiramatsu
Cc: Jim Keniston
Cc: fweisbec@gmail.com
LKML-Reference:
Signed-off-by: Ingo Molnar
17 Oct, 2009
1 commit
-
Conflicts:
kernel/trace/trace_event_profile.cMerge reason: update to -rc5 and resolve conflict.
Signed-off-by: Ingo Molnar
02 Oct, 2009
1 commit
-
[akpm@linux-foundation.org: fix KVM]
Signed-off-by: Alexey Dobriyan
Acked-by: Mike Frysinger
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
24 Sep, 2009
1 commit
-
Conflicts:
kernel/trace/Makefile
kernel/trace/trace.h
kernel/trace/trace_event_types.h
kernel/trace/trace_export.cMerge reason:
Sync with latest significant tracing core changes.
23 Sep, 2009
1 commit
-
Make all seq_operations structs const, to help mitigate against
revectoring user-triggerable function pointers.This is derived from the grsecurity patch, although generated from scratch
because it's simpler than extracting the changes from there.Signed-off-by: James Morris
Acked-by: Serge Hallyn
Acked-by: Casey Schaufler
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
17 Sep, 2009
1 commit
-
Prevent re-registration of the same kprobe. This situation, though
unlikely, needs to be flagged since it can lead to a system crash if
it's not handled.The core change itself is small, but the helper routine needed to be
moved around a bit; hence the diffstat.Signed-off-by: Ananth N Mavinakayanahalli
Acked-by: Masami Hiramatsu
Cc: Jim Keniston
Cc: Andi Kleen
Cc: Christoph Hellwig
Cc: Frank Ch. Eigler
Cc: Frederic Weisbecker
Cc: H. Peter Anvin
Cc: Ingo Molnar
Cc: Jason Baron
Cc: K.Prasad
Cc: Lai Jiangshan
Cc: Li Zefan
Cc: Peter Zijlstra
Cc: Srikar Dronamraju
Cc: Steven Rostedt
Cc: Tom Zanussi
LKML-Reference:
Signed-off-by: Frederic Weisbecker
11 Sep, 2009
1 commit
-
Move irq-exit functions to .kprobes.text section to protect against
kprobes recursion.When I ran kprobe stress test on x86-32, I found below symbols
cause unrecoverable recursive probing:ret_from_exception
ret_from_intr
check_userspace
restore_all
restore_all_notrace
restore_nocheck
irq_returnAnd also, I found some interrupt/exception entry points that
cause similar problems.This patch moves those symbols (including their container functions)
to .kprobes.text section to prevent any kprobes probing.Signed-off-by: Masami Hiramatsu
Cc: Frederic Weisbecker
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Ingo Molnar
LKML-Reference:
Signed-off-by: Frederic Weisbecker
30 Aug, 2009
1 commit
-
Since do_debug() calls get_debugreg(), native_get_debugreg() will be
called from singlestepping. This can cause an int3 infinite loop.We can't put it in the .text.kprobes section because it is inlined,
then we blacklist its name.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Ingo Molnar
LKML-Reference:
Signed-off-by: Frederic Weisbecker
27 Aug, 2009
1 commit
-
Kprobes can enter into a probing recursion, ie: a kprobe that does an
endless loop because one of its core mechanism function used during
probing is also probed itself.This patch helps pinpointing the kprobe that raised such recursion
by dumping it and raising a BUG instead of a warning (we also disarm
the kprobe to try avoiding recursion in BUG itself). Having a BUG
instead of a warning stops the stacktrace in the right place and
doesn't pollute the logs with hundreds of traces that eventually end
up in a stack overflow.Signed-off-by: Frederic Weisbecker
Cc: Masami Hiramatsu
Cc: Ananth N Mavinakayanahalli
11 Aug, 2009
1 commit
-
Conflicts:
kernel/trace/trace_events_filter.cWe use the tracing/core version.
Signed-off-by: Ingo Molnar
31 Jul, 2009
1 commit
-
Use kernel_text_address() for checking probe address instead of
__kernel_text_address(), because __kernel_text_address() returns true
for init functions even after relaseing those functions.That will hit a BUG() in text_poke().
Signed-off-by: Masami Hiramatsu
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Signed-off-by: Linus Torvalds
01 Jul, 2009
2 commits
-
Use struct list instead of struct hlist for managing
insn_pages, because insn_pages doesn't use hash table.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Ananth N Mavinakayanahalli
LKML-Reference:
Signed-off-by: Ingo Molnar -
Remove needless kprobe_insn_mutex unlocking during safety check
in garbage collection, because if someone releases a dirty slot
during safety check (which ensures other cpus doesn't execute
all dirty slots), the safety check must be fail. So, we need to
hold the mutex while checking safety.Signed-off-by: Masami Hiramatsu
Cc: Ananth N Mavinakayanahalli
Cc: Jim Keniston
Cc: Ananth N Mavinakayanahalli
LKML-Reference:
Signed-off-by: Ingo Molnar
09 May, 2009
1 commit
-
Fix kprobes to lock text_mutex around some arch_arm/disarm_kprobe() which
are newly added by commit de5bd88d5a5cce3cacea904d3503e5ebdb3852a2.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Mathieu Desnoyers
Cc: Jim Keniston
Cc: Ingo Molnar
Signed-off-by: Linus Torvalds
07 Apr, 2009
4 commits
-
Add disable_kprobe() and enable_kprobe() to disable/enable kprobes
temporarily.disable_kprobe() asynchronously disables probe handlers of specified
kprobe. So, after calling it, some handlers can be called at a while.
enable_kprobe() enables specified kprobe.aggr_pre_handler and aggr_post_handler check disabled probes. On the
other hand aggr_break_handler and aggr_fault_handler don't check it
because these handlers will be called while executing pre or post handlers
and usually those help error handling.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Cc: David S. Miller
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Rename kprobe_enabled to kprobes_all_disarmed and invert logic due to
avoiding naming confusion from per-probe disabling.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Cc: David S. Miller
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Clean up positions of EXPORT_SYMBOL_GPL in kernel/kprobes.c according to
checkpatch.pl.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Cc: David S. Miller
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Currently, kprobes can disable all probes at once, but can't disable it
individually (not unregister, just disable an kprobe, because
unregistering needs to wait for scheduler synchronization). These patches
introduce APIs for on-the-fly per-probe disabling and re-enabling by
dis-arming/re-arming its breakpoint instruction.This patch:
Change old_p to ap in add_new_kprobe() for readability, copy flags member
in add_aggr_kprobe(), and simplify the code flow of
register_aggr_kprobe().Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Cc: David S. Miller
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
18 Mar, 2009
1 commit
-
Fix locking imbalance in kretprobes:
=====================================
[ BUG: bad unlock balance detected! ]
-------------------------------------
kthreadd/2 is trying to release lock (&rp->lock) at:
[] pre_handler_kretprobe+0xea/0xf4
but there are no more locks to release!other info that might help us debug this:
1 lock held by kthreadd/2:
#0: (rcu_read_lock){..--}, at: [] __atomic_notifier_call_chain+0x0/0x5astack backtrace:
Pid: 2, comm: kthreadd Not tainted 2.6.29-rc8 #1
Call Trace:
[] ? printk+0xf/0x17
[] ? pre_handler_kretprobe+0xea/0xf4
[] print_unlock_inbalance_bug+0xc3/0xce
[] ? clocksource_read+0x7/0xa
[] ? getnstimeofday+0x5f/0xf6
[] ? register_lock_class+0x17/0x293
[] ? mark_lock+0x1e/0x30b
[] ? tick_dev_program_event+0x4a/0xbc
[] ? __slab_alloc+0xa5/0x415
[] ? pre_handler_kretprobe+0x28/0xf4
[] ? pre_handler_kretprobe+0xea/0xf4
[] lock_release_non_nested+0xa4/0x1a5
[] ? pre_handler_kretprobe+0xea/0xf4
[] lock_release+0x141/0x166
[] _spin_unlock_irqrestore+0x19/0x50
[] pre_handler_kretprobe+0xea/0xf4
[] kprobe_exceptions_notify+0x1c9/0x43e
[] notifier_call_chain+0x26/0x48
[] __atomic_notifier_call_chain+0x37/0x5a
[] ? __atomic_notifier_call_chain+0x0/0x5a
[] atomic_notifier_call_chain+0xc/0xe
[] notify_die+0x2d/0x2f
[] do_int3+0x1f/0x71
[] int3+0x2c/0x34
[] ? do_fork+0x1/0x288
[] ? kernel_thread+0x71/0x79
[] ? kthread+0x0/0x60
[] ? kthread+0x0/0x60
[] ? kernel_thread_helper+0x0/0x10
[] kthreadd+0xac/0x148
[] ? kthreadd+0x0/0x148
[] kernel_thread_helper+0x7/0x10Signed-off-by: Ananth N Mavinakayanahalli
Tested-by: Bharata B Rao
Cc: Masami Hiramatsu
Cc: Jim Keniston
Cc: Linus Torvalds
Cc: Andrew Morton
Cc: [2.6.29.x, 2.6.28.x, 2.6.27.x]
LKML-Reference:
Signed-off-by: Ingo Molnar
06 Mar, 2009
1 commit
-
Use the mutual exclusion provided by the text edit lock in the kprobes code. It
allows coherent manipulation of the kernel code by other subsystems.Changelog:
Move the kernel_text_lock/unlock out of the for loops.
Use text_mutex directly instead of a function.
Remove whitespace modifications.(note : kprobes_mutex is always taken outside of text_mutex)
Signed-off-by: Mathieu Desnoyers
Acked-by: Ananth N Mavinakayanahalli
Acked-by: Masami Hiramatsu
LKML-Reference:
Signed-off-by: Ingo Molnar
17 Jan, 2009
1 commit
-
Check CONFIG_FREEZER instead of CONFIG_PM because kprobe booster
depends on freeze_processes() and thaw_processes() when CONFIG_PREEMPT=y.This fixes a linkage error which occurs when CONFIG_PREEMPT=y, CONFIG_PM=y
and CONFIG_FREEZER=n.Reported-by: Cheng Renquan
Signed-off-by: Masami Hiramatsu
Signed-off-by: Rafael J. Wysocki
Acked-by: Ingo Molnar
Signed-off-by: Len Brown
07 Jan, 2009
3 commits
-
Allow kprobes to probe module __init routines. When __init functions are
freed, kprobes which probe those functions are set to "Gone" flag. These
"Gone" probes are disarmed from the code and never be enabled.Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Remove called_from argument from kprobes which had been used for
preventing self-refering of kernel module. However, since we don't keep
module's refcount after registering kprobe any more, there is no reason to
check that.This patch also simplifies registering/unregistering functions because we
don't need to use __builtin_return_address(0) which was passed to
called_from.[ananth@in.ibm.com: build fix]
Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Signed-off-by: Ananth N Mavinakayanahalli
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Allows kprobes to probe __exit routine. This adds flags member to struct
kprobe. When module is freed(kprobes hooks module_notifier to get this
event), kprobes which probe the functions in that module are set to "Gone"
flag to the flags member. These "Gone" probes are never be enabled.
Users can check the GONE flag through debugfs.This also removes mod_refcounted, because we couldn't free a module if
kprobe incremented the refcount of that module.[akpm@linux-foundation.org: document some locking]
[mhiramat@redhat.com: bugfix: pass aggr_kprobe to arch_remove_kprobe]
[mhiramat@redhat.com: bugfix: release old_p's insn_slot before error return]
Signed-off-by: Masami Hiramatsu
Acked-by: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Signed-off-by: Masami Hiramatsu
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds