14 Feb, 2015

2 commits

  • debugfs/kprobes/enabled doesn't work correctly on optimized kprobes.
    Masami Hiramatsu has a test report on x86_64 platform:

    https://lkml.org/lkml/2015/1/19/274

    This patch forces it to unoptimize kprobe if kprobes_all_disarmed is set.
    It also checks the flag in unregistering path for skipping unneeded
    disarming process when kprobes globally disarmed.

    Signed-off-by: Wang Nan
    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wang Nan
     
  • In original code, the probed instruction doesn't get optimized after

    echo 0 > /sys/kernel/debug/kprobes/enabled
    echo 1 > /sys/kernel/debug/kprobes/enabled

    This is because original code checks kprobes_all_disarmed in
    optimize_kprobe(), but this flag is turned off after calling that
    function. Therefore, optimize_kprobe() will see kprobes_all_disarmed ==
    true and doesn't do the optimization.

    This patch simply turns off kprobes_all_disarmed earlier to enable
    optimization.

    Signed-off-by: Wang Nan
    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wang Nan
     

13 Feb, 2015

1 commit

  • Pull ARM updates from Russell King:

    - clang assembly fixes from Ard

    - optimisations and cleanups for Aurora L2 cache support

    - efficient L2 cache support for secure monitor API on Exynos SoCs

    - debug menu cleanup from Daniel Thompson to allow better behaviour for
    multiplatform kernels

    - StrongARM SA11x0 conversion to irq domains, and pxa_timer

    - kprobes updates for older ARM CPUs

    - move probes support out of arch/arm/kernel to arch/arm/probes

    - add inline asm support for the rbit (reverse bits) instruction

    - provide an ARM mode secondary CPU entry point (for Qualcomm CPUs)

    - remove the unused ARMv3 user access code

    - add driver_override support to AMBA Primecell bus

    * 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: (55 commits)
    ARM: 8256/1: driver coamba: add device binding path 'driver_override'
    ARM: 8301/1: qcom: Use secondary_startup_arm()
    ARM: 8302/1: Add a secondary_startup that assumes ARM mode
    ARM: 8300/1: teach __asmeq that r11 == fp and r12 == ip
    ARM: kprobes: Fix compilation error caused by superfluous '*'
    ARM: 8297/1: cache-l2x0: optimize aurora range operations
    ARM: 8296/1: cache-l2x0: clean up aurora cache handling
    ARM: 8284/1: sa1100: clear RCSR_SMR on resume
    ARM: 8283/1: sa1100: collie: clear PWER register on machine init
    ARM: 8282/1: sa1100: use handle_domain_irq
    ARM: 8281/1: sa1100: move GPIO-related IRQ code to gpio driver
    ARM: 8280/1: sa1100: switch to irq_domain_add_simple()
    ARM: 8279/1: sa1100: merge both GPIO irqdomains
    ARM: 8278/1: sa1100: split irq handling for low GPIOs
    ARM: 8291/1: replace magic number with PAGE_SHIFT macro in fixup_pv code
    ARM: 8290/1: decompressor: fix a wrong comment
    ARM: 8286/1: mm: Fix dma_contiguous_reserve comment
    ARM: 8248/1: pm: remove outdated comment
    ARM: 8274/1: Fix DEBUG_LL for multi-platform kernels (without PL01X)
    ARM: 8273/1: Seperate DEBUG_UART_PHYS from DEBUG_LL on EP93XX
    ...

    Linus Torvalds
     

20 Jan, 2015

1 commit

  • Nothing needs the module pointer any more, and the next patch will
    call it from RCU, where the module itself might no longer exist.
    Removing the arg is the safest approach.

    This just codifies the use of the module_alloc/module_free pattern
    which ftrace and bpf use.

    Signed-off-by: Rusty Russell
    Acked-by: Alexei Starovoitov
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: Ralf Baechle
    Cc: Ley Foon Tan
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Steven Rostedt
    Cc: x86@kernel.org
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Masami Hiramatsu
    Cc: linux-cris-kernel@axis.com
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: nios2-dev@lists.rocketboards.org
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: sparclinux@vger.kernel.org
    Cc: netdev@vger.kernel.org

    Rusty Russell
     

14 Jan, 2015

1 commit


12 Dec, 2014

1 commit

  • Pull s390 updates from Martin Schwidefsky:
    "The most notable change for this pull request is the ftrace rework
    from Heiko. It brings a small performance improvement and the ground
    work to support a new gcc option to replace the mcount blocks with a
    single nop.

    Two new s390 specific system calls are added to emulate user space
    mmio for PCI, an artifact of the how PCI memory is accessed.

    Two patches for the memory management with changes to common code.
    For KVM mm_forbids_zeropage is added which disables the empty zero
    page for an mm that is used by a KVM process. And an optimization,
    pmdp_get_and_clear_full is added analog to ptep_get_and_clear_full.

    Some micro optimization for the cmpxchg and the spinlock code.

    And as usual bug fixes and cleanups"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (46 commits)
    s390/cputime: fix 31-bit compile
    s390/scm_block: make the number of reqs per HW req configurable
    s390/scm_block: handle multiple requests in one HW request
    s390/scm_block: allocate aidaw pages only when necessary
    s390/scm_block: use mempool to manage aidaw requests
    s390/eadm: change timeout value
    s390/mm: fix memory leak of ptlock in pmd_free_tlb
    s390: use local symbol names in entry[64].S
    s390/ptrace: always include vector registers in core files
    s390/simd: clear vector register pointer on fork/clone
    s390: translate cputime magic constants to macros
    s390/idle: convert open coded idle time seqcount
    s390/idle: add missing irq off lockdep annotation
    s390/debug: avoid function call for debug_sprintf_*
    s390/kprobes: fix instruction copy for out of line execution
    s390: remove diag 44 calls from cpu_relax()
    s390/dasd: retry partition detection
    s390/dasd: fix list corruption for sleep_on requests
    s390/dasd: fix infinite term I/O loop
    s390/dasd: remove unused code
    ...

    Linus Torvalds
     

22 Nov, 2014

1 commit


27 Oct, 2014

1 commit

  • Introduce weak arch_check_ftrace_location() helper function which
    architectures can override in order to implement handling of kprobes
    on function tracer call sites on their own, without depending on
    common code or implementing the KPROBES_ON_FTRACE feature.

    Signed-off-by: Heiko Carstens
    Acked-by: Masami Hiramatsu
    Acked-by: Steven Rostedt
    Signed-off-by: Martin Schwidefsky

    Heiko Carstens
     

08 Aug, 2014

1 commit

  • Skip kretprobe hit in NMI context, because if an NMI happens
    inside the critical section protected by kretprobe_table.lock
    and another(or same) kretprobe hit, pre_kretprobe_handler
    tries to lock kretprobe_table.lock again.
    Normal interrupts have no problem because they are disabled
    with the lock.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Ananth N Mavinakayanahalli
    Cc: David S. Miller
    Link: http://lkml.kernel.org/r/20140804031016.11433.65539.stgit@kbuild-fedora.novalocal
    [ Minor edits for clarity. ]
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

18 Jul, 2014

1 commit

  • On ia64 and ppc64, function pointers do not point to the
    entry address of the function, but to the address of a
    function descriptor (which contains the entry address and misc
    data).

    Since the kprobes code passes the function pointer stored
    by NOKPROBE_SYMBOL() to kallsyms_lookup_size_offset() for
    initalizing its blacklist, it fails and reports many errors,
    such as:

    Failed to find blacklist 0001013168300000
    Failed to find blacklist 0001013000f0a000
    [...]

    To fix this bug, use arch_deref_entry_point() to get the
    function entry address for kallsyms_lookup_size_offset()
    instead of the raw function pointer.

    Suzuki also pointed out that blacklist entries should also
    be updated as well.

    Reported-by: Tony Luck
    Fixed-by: Suzuki K. Poulose
    Tested-by: Tony Luck
    Tested-by: Michael Ellerman
    Signed-off-by: Masami Hiramatsu
    Acked-by: Michael Ellerman (for powerpc)
    Acked-by: Benjamin Herrenschmidt
    Cc: Jeremy Fitzhardinge
    Cc: sparse@chrisli.org
    Cc: Paul Mackerras
    Cc: akataria@vmware.com
    Cc: anil.s.keshavamurthy@intel.com
    Cc: Fenghua Yu
    Cc: Arnd Bergmann
    Cc: Rusty Russell
    Cc: Chris Wright
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: Kevin Hao
    Cc: Ananth N Mavinakayanahalli
    Cc: rdunlap@infradead.org
    Cc: dl9pf@gmx.de
    Cc: Linus Torvalds
    Cc: David S. Miller
    Cc: linux-ia64@vger.kernel.org
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/20140717114411.13401.2632.stgit@kbuild-fedora.novalocal
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

24 Apr, 2014

5 commits

  • Show blacklist entries (function names with the address
    range) via /sys/kernel/debug/kprobes/blacklist.

    Note that at this point the blacklist supports only
    in vmlinux, not module. So the list is fixed and
    not updated.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Link: http://lkml.kernel.org/r/20140417081849.26341.11609.stgit@ltc230.yrl.intra.hitachi.co.jp
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Use NOKPROBE_SYMBOL macro to protect functions from
    kprobes instead of __kprobes annotation.

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Link: http://lkml.kernel.org/r/20140417081821.26341.40362.stgit@ltc230.yrl.intra.hitachi.co.jp
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • There is no need to prohibit probing on the functions
    used for preparation, registeration, optimization,
    controll etc. Those are safely probed because those are
    not invoked from breakpoint/fault/debug handlers,
    there is no chance to cause recursive exceptions.

    Following functions are now removed from the kprobes blacklist:

    add_new_kprobe
    aggr_kprobe_disabled
    alloc_aggr_kprobe
    alloc_aggr_kprobe
    arm_all_kprobes
    __arm_kprobe
    arm_kprobe
    arm_kprobe_ftrace
    check_kprobe_address_safe
    collect_garbage_slots
    collect_garbage_slots
    collect_one_slot
    debugfs_kprobe_init
    __disable_kprobe
    disable_kprobe
    disarm_all_kprobes
    __disarm_kprobe
    disarm_kprobe
    disarm_kprobe_ftrace
    do_free_cleaned_kprobes
    do_optimize_kprobes
    do_unoptimize_kprobes
    enable_kprobe
    force_unoptimize_kprobe
    free_aggr_kprobe
    free_aggr_kprobe
    __free_insn_slot
    __get_insn_slot
    get_optimized_kprobe
    __get_valid_kprobe
    init_aggr_kprobe
    init_aggr_kprobe
    in_nokprobe_functions
    kick_kprobe_optimizer
    kill_kprobe
    kill_optimized_kprobe
    kprobe_addr
    kprobe_optimizer
    kprobe_queued
    kprobe_seq_next
    kprobe_seq_start
    kprobe_seq_stop
    kprobes_module_callback
    kprobes_open
    optimize_all_kprobes
    optimize_kprobe
    prepare_kprobe
    prepare_optimized_kprobe
    register_aggr_kprobe
    register_jprobe
    register_jprobes
    register_kprobe
    register_kprobes
    register_kretprobe
    register_kretprobe
    register_kretprobes
    register_kretprobes
    report_probe
    show_kprobe_addr
    try_to_optimize_kprobe
    unoptimize_all_kprobes
    unoptimize_kprobe
    unregister_jprobe
    unregister_jprobes
    unregister_kprobe
    __unregister_kprobe_bottom
    unregister_kprobes
    __unregister_kprobe_top
    unregister_kretprobe
    unregister_kretprobe
    unregister_kretprobes
    unregister_kretprobes
    wait_for_kprobe_optimizer

    I tested those functions by putting kprobes on all
    instructions in the functions with the bash script
    I sent to LKML. See:

    https://lkml.org/lkml/2014/3/27/33

    Signed-off-by: Masami Hiramatsu
    Link: http://lkml.kernel.org/r/20140417081753.26341.57889.stgit@ltc230.yrl.intra.hitachi.co.jp
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Cc: fche@redhat.com
    Cc: systemtap@sourceware.org
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Introduce NOKPROBE_SYMBOL() macro which builds a kprobes
    blacklist at kernel build time.

    The usage of this macro is similar to EXPORT_SYMBOL(),
    placed after the function definition:

    NOKPROBE_SYMBOL(function);

    Since this macro will inhibit inlining of static/inline
    functions, this patch also introduces a nokprobe_inline macro
    for static/inline functions. In this case, we must use
    NOKPROBE_SYMBOL() for the inline function caller.

    When CONFIG_KPROBES=y, the macro stores the given function
    address in the "_kprobe_blacklist" section.

    Since the data structures are not fully initialized by the
    macro (because there is no "size" information), those
    are re-initialized at boot time by using kallsyms.

    Signed-off-by: Masami Hiramatsu
    Link: http://lkml.kernel.org/r/20140417081705.26341.96719.stgit@ltc230.yrl.intra.hitachi.co.jp
    Cc: Alok Kataria
    Cc: Ananth N Mavinakayanahalli
    Cc: Andrew Morton
    Cc: Anil S Keshavamurthy
    Cc: Arnd Bergmann
    Cc: Christopher Li
    Cc: Chris Wright
    Cc: David S. Miller
    Cc: Jan-Simon Möller
    Cc: Jeremy Fitzhardinge
    Cc: Linus Torvalds
    Cc: Randy Dunlap
    Cc: Rusty Russell
    Cc: linux-arch@vger.kernel.org
    Cc: linux-doc@vger.kernel.org
    Cc: linux-sparse@vger.kernel.org
    Cc: virtualization@lists.linux-foundation.org
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • .entry.text is a code area which is used for interrupt/syscall
    entries, which includes many sensitive code.
    Thus, it is better to prohibit probing on all of such code
    instead of a part of that.
    Since some symbols are already registered on kprobe blacklist,
    this also removes them from the blacklist.

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Borislav Petkov
    Cc: David S. Miller
    Cc: Frederic Weisbecker
    Cc: Jan Kiszka
    Cc: Jiri Kosina
    Cc: Jonathan Lebon
    Cc: Seiji Aguchi
    Link: http://lkml.kernel.org/r/20140417081658.26341.57354.stgit@ltc230.yrl.intra.hitachi.co.jp
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

13 Nov, 2013

1 commit


12 Sep, 2013

2 commits

  • The current two insn slot caches both use module_alloc/module_free to
    allocate and free insn slot cache pages.

    For s390 this is not sufficient since there is the need to allocate insn
    slots that are either within the vmalloc module area or within dma memory.

    Therefore add a mechanism which allows to specify an own allocator for an
    own insn slot cache.

    Signed-off-by: Heiko Carstens
    Acked-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Ingo Molnar
    Cc: Martin Schwidefsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     
  • The current kpropes insn caches allocate memory areas for insn slots
    with module_alloc(). The assumption is that the kernel image and module
    area are both within the same +/- 2GB memory area.

    This however is not true for s390 where the kernel image resides within
    the first 2GB (DMA memory area), but the module area is far away in the
    vmalloc area, usually somewhere close below the 4TB area.

    For new pc relative instructions s390 needs insn slots that are within
    +/- 2GB of each area. That way we can patch displacements of
    pc-relative instructions within the insn slots just like x86 and
    powerpc.

    The module area works already with the normal insn slot allocator,
    however there is currently no way to get insn slots that are within the
    first 2GB on s390 (aka DMA area).

    Therefore this patch set modifies the kprobes insn slot cache code in
    order to allow to specify a custom allocator for the insn slot cache
    pages. In addition architecure can now have private insn slot caches
    withhout the need to modify common code.

    Patch 1 unifies and simplifies the current insn and optinsn caches
    implementation. This is a preparation which allows to add more
    insn caches in a simple way.

    Patch 2 adds the possibility to specify a custom allocator.

    Patch 3 makes s390 use the new insn slot mechanisms and adds support for
    pc-relative instructions with long displacements.

    This patch (of 3):

    The two insn caches (insn, and optinsn) each have an own mutex and
    alloc/free functions (get_[opt]insn_slot() / free_[opt]insn_slot()).

    Since there is the need for yet another insn cache which satifies dma
    allocations on s390, unify and simplify the current implementation:

    - Move the per insn cache mutex into struct kprobe_insn_cache.
    - Move the alloc/free functions to kprobe.h so they are simply
    wrappers for the generic __get_insn_slot/__free_insn_slot functions.
    The implementation is done with a DEFINE_INSN_CACHE_OPS() macro
    which provides the alloc/free functions for each cache if needed.
    - move the struct kprobe_insn_cache to kprobe.h which allows to generate
    architecture specific insn slot caches outside of the core kprobes
    code.

    Signed-off-by: Heiko Carstens
    Cc: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Ingo Molnar
    Cc: Martin Schwidefsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

04 Jul, 2013

1 commit

  • When writing invalid input to 'debug/kprobes/enabled' it'll silently be
    ignored. Even worse, when writing an empty string to this file, the
    outcome is purely random as the switch statement will make its decision
    based on the value of an uninitialized stack variable.

    Fix this by handling invalid/empty input as error returning -EINVAL.

    Signed-off-by: Mathias Krause
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: "David S. Miller"
    Cc: Masami Hiramatsu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mathias Krause
     

28 May, 2013

1 commit

  • Fix to free gone and unused optprobes. This bug will
    cause a kernel panic if the user reuses the killed and
    unused probe.

    Reported at:

    http://sourceware.org/ml/systemtap/2013-q2/msg00142.html

    In the normal path, an optprobe on an init function is
    unregistered when a module goes live.

    unregister_kprobe(kp)
    -> __unregister_kprobe_top
    ->__disable_kprobe
    ->disarm_kprobe(ap == op)
    ->__disarm_kprobe
    ->unoptimize_kprobe : the op is queued
    on unoptimizing_list
    and do nothing in __unregister_kprobe_bottom

    After a while (usually wait 5 jiffies), kprobe_optimizer
    runs to unoptimize and free optprobe.

    kprobe_optimizer
    ->do_unoptimize_kprobes
    ->arch_unoptimize_kprobes : moved to free_list
    ->do_free_cleaned_kprobes
    ->hlist_del: the op is removed
    ->free_aggr_kprobe
    ->arch_remove_optimized_kprobe
    ->arch_remove_kprobe
    ->kfree: the op is freed

    Here, if kprobes_module_callback is called and the delayed
    unoptimizing probe is picked BEFORE kprobe_optimizer runs,

    kprobes_module_callback
    ->kill_kprobe
    ->kill_optimized_kprobe : dequeued from unoptimizing_list arch_remove_optimized_kprobe
    ->arch_remove_kprobe
    (but op is not freed, and on the kprobe hash table)

    This doesn't happen if the probe unregistration is done AFTER
    kprobes_module_callback is called (because at that time the op
    is gone), and kprobe-tracer does it.

    To fix this bug, this patch changes kprobes_module_callback to
    enqueue the op to freeing_list at kill_optimized_kprobe only
    if the op is unused. The unused probes on freeing_list will
    be freed in do_free_cleaned_kprobes.

    Note that this calls arch_remove_*kprobe twice on the
    same probe. Thus those functions have to check the double free.
    Fortunately, most of arch codes already checked that except
    for mips. This will be fixed in the next patch.

    Signed-off-by: Masami Hiramatsu
    Cc: Timo Juhani Lindfors
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Frank Ch. Eigler
    Cc: systemtap@sourceware.org
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: David S. Miller
    Cc: "David S. Miller"
    Link: http://lkml.kernel.org/r/20130522093409.9084.63554.stgit@mhiramat-M0-7522
    [ Minor edits. ]
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

18 Apr, 2013

1 commit

  • Fix a double locking bug caused when debug.kprobe-optimization=0.
    While the proc_kprobes_optimization_handler locks kprobe_mutex,
    wait_for_kprobe_optimizer locks it again and that causes a double lock.
    To fix the bug, this introduces different mutex for protecting
    sysctl parameter and locks it in proc_kprobes_optimization_handler.
    Of course, since we need to lock kprobe_mutex when touching kprobes
    resources, that is done in *optimize_all_kprobes().

    This bug was introduced by commit ad72b3bea744 ("kprobes: fix
    wait_for_kprobe_optimizer()")

    Signed-off-by: Masami Hiramatsu
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Ingo Molnar
    Cc: Tejun Heo
    Cc: "David S. Miller"
    Signed-off-by: Linus Torvalds

    Masami Hiramatsu
     

28 Feb, 2013

1 commit

  • I'm not sure why, but the hlist for each entry iterators were conceived

    list_for_each_entry(pos, head, member)

    The hlist ones were greedy and wanted an extra parameter:

    hlist_for_each_entry(tpos, pos, head, member)

    Why did they need an extra pos parameter? I'm not quite sure. Not only
    they don't really need it, it also prevents the iterator from looking
    exactly like the list iterator, which is unfortunate.

    Besides the semantic patch, there was some manual work required:

    - Fix up the actual hlist iterators in linux/list.h
    - Fix up the declaration of other iterators based on the hlist ones.
    - A very small amount of places were using the 'node' parameter, this
    was modified to use 'obj->member' instead.
    - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
    properly, so those had to be fixed up manually.

    The semantic patch which is mostly the work of Peter Senna Tschudin is here:

    @@
    iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

    type T;
    expression a,c,d,e;
    identifier b;
    statement S;
    @@

    -T b;

    [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
    [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
    [akpm@linux-foundation.org: checkpatch fixes]
    [akpm@linux-foundation.org: fix warnings]
    [akpm@linux-foudnation.org: redo intrusive kvm changes]
    Tested-by: Peter Senna Tschudin
    Acked-by: Paul E. McKenney
    Signed-off-by: Sasha Levin
    Cc: Wu Fengguang
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin
     

20 Feb, 2013

1 commit

  • Pull workqueue [delayed_]work_pending() cleanups from Tejun Heo:
    "This is part of on-going cleanups to remove / minimize usages of
    workqueue interfaces which are deprecated and/or misleading.

    This round drops a number of usages of [delayed_]work_pending(), which
    are dangerous as they lack any form of synchronization and thus often
    lead to buggy / unnecessary code. There are a couple legitimate use
    cases in kernel. Hopefully, they can be converted and
    [delayed_]work_pending() can be removed completely. Even if not,
    removing most of misuses should make it more difficult to find
    examples of misuses and thus slow down growth of them.

    These changes are independent from other workqueue changes."

    * 'for-3.9-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
    wimax/i2400m: fix i2400m->wake_tx_skb handling
    kprobes: fix wait_for_kprobe_optimizer()
    ipw2x00: simplify scan_event handling
    video/exynos: don't use [delayed_]work_pending()
    tty/max3100: don't use [delayed_]work_pending()
    x86/mce: don't use [delayed_]work_pending()
    rfkill: don't use [delayed_]work_pending()
    wl1251: don't use [delayed_]work_pending()
    thinkpad_acpi: don't use [delayed_]work_pending()
    mwifiex: don't use [delayed_]work_pending()
    sja1000: don't use [delayed_]work_pending()

    Linus Torvalds
     

10 Feb, 2013

1 commit

  • wait_for_kprobe_optimizer() seems largely broken. It uses
    optimizer_comp which is never re-initialized, so
    wait_for_kprobe_optimizer() will never wait for anything once
    kprobe_optimizer() finishes all pending jobs for the first time.

    Also, aside from completion, delayed_work_pending() is %false once
    kprobe_optimizer() starts execution and wait_for_kprobe_optimizer()
    won't wait for it.

    Reimplement it so that it flushes optimizing_work until
    [un]optimizing_lists are empty. Note that this also makes
    optimizing_work execute immediately if someone's waiting for it, which
    is the nicer behavior.

    Only compile tested.

    Signed-off-by: Tejun Heo
    Acked-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: "David S. Miller"

    Tejun Heo
     

22 Jan, 2013

1 commit

  • Split ftrace-based kprobes code from kprobes, and introduce
    CONFIG_(HAVE_)KPROBES_ON_FTRACE Kconfig flags.
    For the cleanup reason, this also moves kprobe_ftrace check
    into skip_singlestep.

    Link: http://lkml.kernel.org/r/20120928081520.3560.25624.stgit@ltc138.sdl.hitachi.co.jp

    Cc: Ingo Molnar
    Cc: Ananth N Mavinakayanahalli
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Frederic Weisbecker
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

14 Sep, 2012

1 commit

  • Fix kprobes/x86 to support jprobes on ftrace-based kprobes.
    Because of -mfentry support of ftrace, ftrace is now put
    on the beginning of function where jprobes are put.

    Originally ftrace-based kprobes doesn't support jprobe
    because it will change regs->ip and ftrace doesn't support
    changing IP and ftrace itself doesn't conflict jprobe.
    However, ftrace -mfentry support moves mcount call on the
    top of functions where jprobes are put. This means that
    jprobe always conflicts with ftrace-based kprobe and fails.

    This patch allows ftrace-based kprobes to support jprobes
    by allowing to modify regs->ip and kprobes breakpoint
    handler also allows to skip singlestepping because there
    is a ftrace call (not an original instruction).

    Link: http://lkml.kernel.org/r/20120905143125.10329.90836.stgit@localhost.localdomain

    Reported-by: Fengguang Wu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

31 Jul, 2012

5 commits

  • Add function tracer based kprobe optimization support
    handlers on x86. This allows kprobes to use function
    tracer for probing on mcount call.

    Link: http://lkml.kernel.org/r/20120605102838.27845.26317.stgit@localhost.localdomain

    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Ananth N Mavinakayanahalli
    Cc: "Frank Ch. Eigler"
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Signed-off-by: Masami Hiramatsu

    [ Updated to new port of ftrace save regs functions ]

    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Introduce function trace based kprobes optimization.

    With using ftrace optimization, kprobes on the mcount calling
    address, use ftrace's mcount call instead of breakpoint.
    Furthermore, this optimization works with preemptive kernel
    not like as current jump-based optimization. Of cource,
    this feature works only if the probe is on mcount call.

    Only if kprobe.break_handler is set, that probe is not
    optimized with ftrace (nor put on ftrace). The reason why this
    limitation comes is that this break_handler may be used only
    from jprobes which changes ip address (for fetching the function
    arguments), but function tracer ignores modified ip address.

    Changes in v2:
    - Fix ftrace_ops registering right after setting its filter.
    - Unregister ftrace_ops if there is no kprobe using.
    - Remove notrace dependency from __kprobes macro.

    Link: http://lkml.kernel.org/r/20120605102832.27845.63461.stgit@localhost.localdomain

    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Ananth N Mavinakayanahalli
    Cc: "Frank Ch. Eigler"
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Break a big critical region into fine-grained pieces at
    registering kprobe path. This helps us to solve circular
    locking dependency when introducing ftrace-based kprobes.

    Link: http://lkml.kernel.org/r/20120605102826.27845.81689.stgit@localhost.localdomain

    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Ananth N Mavinakayanahalli
    Cc: "Frank Ch. Eigler"
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Separate probe-able address checking code from
    register_kprobe().

    Link: http://lkml.kernel.org/r/20120605102820.27845.90133.stgit@localhost.localdomain

    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Ananth N Mavinakayanahalli
    Cc: "Frank Ch. Eigler"
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Currently module_mutex is taken before kprobe_mutex, but this
    can cause issues when we have kprobes register ftrace, as the ftrace
    mutex is taken before enabling a tracepoint, which currently takes
    the module mutex.

    If module_mutex is taken before kprobe_mutex, then we can not
    have kprobes use the ftrace infrastructure.

    There seems to be no reason that the kprobe_mutex can't be taken
    before the module_mutex. Running lockdep shows that it is safe
    among the kernels I've run.

    Link: http://lkml.kernel.org/r/20120605102814.27845.21047.stgit@localhost.localdomain

    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Ananth N Mavinakayanahalli
    Cc: "Frank Ch. Eigler"
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Cc: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

06 Mar, 2012

1 commit

  • register_kprobe() aborts if the address of the new request falls in a
    prohibited area (such as ftrace pouch, __kprobes annotated functions,
    non-kernel text addresses, jump label text). We however don't return the
    right error on this abort, resulting in a silent failure - incorrect
    adding/reporting of kprobes ('perf probe do_fork+18' or 'perf probe
    mcount' for instance).

    In V2 we are incorporating Masami Hiramatsu's feedback.

    This patch fixes it by returning -EINVAL upon failure.

    While we are here, rename the label used for exit to be more appropriate.

    Signed-off-by: Ananth N Mavinakayanahalli
    Signed-off-by: Prashanth K Nageshappa
    Acked-by: Masami Hiramatsu
    Cc: Jason Baron
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Prashanth Nageshappa
     

04 Feb, 2012

1 commit

  • In function pre_handler_kretprobe(), the allocated kretprobe_instance
    object will get leaked if the entry_handler callback returns non-zero.
    This may cause all the preallocated kretprobe_instance objects exhausted.

    This issue can be reproduced by changing
    samples/kprobes/kretprobe_example.c to probe "mutex_unlock". And the fix
    is straightforward: just put the allocated kretprobe_instance object back
    onto the free_instances list.

    [akpm@linux-foundation.org: use raw_spin_lock/unlock]
    Signed-off-by: Jiang Liu
    Acked-by: Jim Keniston
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Masami Hiramatsu
    Cc: Anil S Keshavamurthy
    Cc: "David S. Miller"
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiang Liu
     

24 Jan, 2012

1 commit

  • Commit ef53d9c5e ("kprobes: improve kretprobe scalability with hashed
    locking") introduced a bug where we can potentially leak
    kretprobe_instances since we initialize a hlist head after having used
    it.

    Initialize the hlist head before using it.

    Reported by: Jim Keniston
    Acked-by: Jim Keniston
    Signed-off-by: Ananth N Mavinakayanahalli
    Acked-by: Masami Hiramatsu
    Cc: Srinivasa D S
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ananth N Mavinakayanahalli
     

13 Jan, 2012

1 commit

  • Enabling DEBUG_STRICT_USER_COPY_CHECKS causes the following warning:

    In file included from arch/x86/include/asm/uaccess.h:573,
    from kernel/kprobes.c:55:
    In function 'copy_from_user',
    inlined from 'write_enabled_file_bool' at
    kernel/kprobes.c:2191:
    arch/x86/include/asm/uaccess_64.h:65:
    warning: call to 'copy_from_user_overflow' declared with attribute warning: copy_from_user() buffer size is not provably correct

    presumably due to buf_size being signed causing GCC to fail to see that
    buf_size can't become negative.

    Signed-off-by: Stephen Boyd
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Acked-by: Masami Hiramatsu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     

31 Oct, 2011

1 commit

  • The changed files were only including linux/module.h for the
    EXPORT_SYMBOL infrastructure, and nothing else. Revector them
    onto the isolated export header for faster compile times.

    Nothing to see here but a whole lot of instances of:

    -#include
    +#include

    This commit is only changing the kernel dir; next targets
    will probably be mm, fs, the arch dirs, etc.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

13 Sep, 2011

1 commit


16 Jul, 2011

1 commit

  • Return -ENOENT if probe point doesn't exist, but still returns
    -EINVAL if both of kprobe->addr and kprobe->symbol_name are
    specified or both are not specified.

    Acked-by: Ananth N Mavinakayanahalli
    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Anil S Keshavamurthy
    Cc: "David S. Miller"
    Link: http://lkml.kernel.org/r/20110627072650.6528.67329.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

08 Jan, 2011

1 commit

  • * 'for-2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu: (30 commits)
    gameport: use this_cpu_read instead of lookup
    x86: udelay: Use this_cpu_read to avoid address calculation
    x86: Use this_cpu_inc_return for nmi counter
    x86: Replace uses of current_cpu_data with this_cpu ops
    x86: Use this_cpu_ops to optimize code
    vmstat: User per cpu atomics to avoid interrupt disable / enable
    irq_work: Use per cpu atomics instead of regular atomics
    cpuops: Use cmpxchg for xchg to avoid lock semantics
    x86: this_cpu_cmpxchg and this_cpu_xchg operations
    percpu: Generic this_cpu_cmpxchg() and this_cpu_xchg support
    percpu,x86: relocate this_cpu_add_return() and friends
    connector: Use this_cpu operations
    xen: Use this_cpu_inc_return
    taskstats: Use this_cpu_ops
    random: Use this_cpu_inc_return
    fs: Use this_cpu_inc_return in buffer.c
    highmem: Use this_cpu_xx_return() operations
    vmstat: Use this_cpu_inc_return for vm statistics
    x86: Support for this_cpu_add, sub, dec, inc_return
    percpu: Generic support for this_cpu_add, sub, dec, inc_return
    ...

    Fixed up conflicts: in arch/x86/kernel/{apic/nmi.c, apic/x2apic_uv_x.c, process.c}
    as per Tejun.

    Linus Torvalds
     

17 Dec, 2010

1 commit