14 Nov, 2018

1 commit

  • [ Upstream commit 819319fc93461c07b9cdb3064f154bd8cfd48172 ]

    Make reuse_unused_kprobe() to return error code if
    it fails to reuse unused kprobe for optprobe instead
    of calling BUG_ON().

    Signed-off-by: Masami Hiramatsu
    Cc: Anil S Keshavamurthy
    Cc: David S . Miller
    Cc: Linus Torvalds
    Cc: Naveen N . Rao
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/153666124040.21306.14150398706331307654.stgit@devbox
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

05 Sep, 2018

1 commit

  • commit f2a3ab36077222437b4826fc76111caa14562b7c upstream.

    Since the blacklist and list files on debugfs indicates
    a sensitive address information to reader, it should be
    restricted to the root user.

    Suggested-by: Thomas Richter
    Suggested-by: Ingo Molnar
    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Arnd Bergmann
    Cc: David Howells
    Cc: David S . Miller
    Cc: Heiko Carstens
    Cc: Jon Medhurst
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Tobin C . Harding
    Cc: Will Deacon
    Cc: acme@kernel.org
    Cc: akpm@linux-foundation.org
    Cc: brueckner@linux.vnet.ibm.com
    Cc: linux-arch@vger.kernel.org
    Cc: rostedt@goodmis.org
    Cc: schwidefsky@de.ibm.com
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/lkml/152491890171.9916.5183693615601334087.stgit@devbox
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

10 Dec, 2017

1 commit

  • [ Upstream commit a30b85df7d599f626973e9cd3056fe755bd778e0 ]

    We want to wait for all potentially preempted kprobes trampoline
    execution to have completed. This guarantees that any freed
    trampoline memory is not in use by any task in the system anymore.
    synchronize_rcu_tasks() gives such a guarantee, so use it.

    Also, this guarantees to wait for all potentially preempted tasks
    on the instructions which will be replaced with a jump.

    Since this becomes a problem only when CONFIG_PREEMPT=y, enable
    CONFIG_TASKS_RCU=y for synchronize_rcu_tasks() in that case.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Paul E. McKenney
    Cc: Ananth N Mavinakayanahalli
    Cc: Linus Torvalds
    Cc: Naveen N . Rao
    Cc: Paul E . McKenney
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/150845661962.5443.17724352636247312231.stgit@devbox
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

08 Jul, 2017

3 commits

  • Similar to commit 90ec5e89e393c ("kretprobes: Ensure probe location is
    at function entry"), ensure that the jprobe probepoint is at function
    entry.

    Signed-off-by: Naveen N. Rao
    Cc: Ananth N Mavinakayanahalli
    Cc: Linus Torvalds
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/a4525af6c5a42df385efa31251246cf7cca73598.1499443367.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Naveen N. Rao
     
  • Re-factor jprobe registration functions as the current version is
    getting too unwieldy. Move the actual jprobe registration to
    register_jprobe() and re-organize code accordingly.

    Suggested-by: Ingo Molnar
    Signed-off-by: Naveen N. Rao
    Cc: Ananth N Mavinakayanahalli
    Cc: Linus Torvalds
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/089cae4bfe73767f765291ee0e6fb0c3d240e5f1.1499443367.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Naveen N. Rao
     
  • Rename function_offset_within_entry() to scope it to kprobe namespace by
    using kprobe_ prefix, and to also simplify it.

    Suggested-by: Ingo Molnar
    Suggested-by: Masami Hiramatsu
    Signed-off-by: Naveen N. Rao
    Cc: Ananth N Mavinakayanahalli
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/3aa6c7e2e4fb6e00f3c24fa306496a66edb558ea.1499443367.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Naveen N. Rao
     

04 Jul, 2017

1 commit

  • Pull SMP hotplug updates from Thomas Gleixner:
    "This update is primarily a cleanup of the CPU hotplug locking code.

    The hotplug locking mechanism is an open coded RWSEM, which allows
    recursive locking. The main problem with that is the recursive nature
    as it evades the full lockdep coverage and hides potential deadlocks.

    The rework replaces the open coded RWSEM with a percpu RWSEM and
    establishes full lockdep coverage that way.

    The bulk of the changes fix up recursive locking issues and address
    the now fully reported potential deadlocks all over the place. Some of
    these deadlocks have been observed in the RT tree, but on mainline the
    probability was low enough to hide them away."

    * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (37 commits)
    cpu/hotplug: Constify attribute_group structures
    powerpc: Only obtain cpu_hotplug_lock if called by rtasd
    ARM/hw_breakpoint: Fix possible recursive locking for arch_hw_breakpoint_init
    cpu/hotplug: Remove unused check_for_tasks() function
    perf/core: Don't release cred_guard_mutex if not taken
    cpuhotplug: Link lock stacks for hotplug callbacks
    acpi/processor: Prevent cpu hotplug deadlock
    sched: Provide is_percpu_thread() helper
    cpu/hotplug: Convert hotplug locking to percpu rwsem
    s390: Prevent hotplug rwsem recursion
    arm: Prevent hotplug rwsem recursion
    arm64: Prevent cpu hotplug rwsem recursion
    kprobes: Cure hotplug lock ordering issues
    jump_label: Reorder hotplug lock and jump_label_lock
    perf/tracing/cpuhotplug: Fix locking order
    ACPI/processor: Use cpu_hotplug_disable() instead of get_online_cpus()
    PCI: Replace the racy recursion prevention
    PCI: Use cpu_hotplug_disable() instead of get_online_cpus()
    perf/x86/intel: Drop get_online_cpus() in intel_snb_check_microcode()
    x86/perf: Drop EXPORT of perf_check_microcode
    ...

    Linus Torvalds
     

27 May, 2017

1 commit

  • Fix kprobes to set(recover) RWX bits correctly on trampoline
    buffer before releasing it. Releasing readonly page to
    module_memfree() crash the kernel.

    Without this fix, if kprobes user register a bunch of kprobes
    in function body (since kprobes on function entry usually
    use ftrace) and unregister it, kernel hits a BUG and crash.

    Link: http://lkml.kernel.org/r/149570868652.3518.14120169373590420503.stgit@devbox

    Signed-off-by: Masami Hiramatsu
    Fixes: d0381c81c2f7 ("kprobes/x86: Set kprobes pages read-only")
    Signed-off-by: Steven Rostedt (VMware)

    Masami Hiramatsu
     

26 May, 2017

1 commit

  • Converting the cpu hotplug locking to a percpu rwsem unearthed hidden lock
    ordering problems.

    There is a wide range of locks involved in this: kprobe_mutex,
    jump_label_mutex, ftrace_lock, text_mutex, event_mutex, module_mutex,
    func_hash->regex_lock and a gazillion of lock order permutations with
    nested get_online_cpus() calls.

    Some of those permutations are potential deadlocks even with the current
    nesting hotplug locking scheme, but they can't be discovered by lockdep.

    The conversion of the hotplug locking to a percpu rwsem requires to prevent
    nested locking, so it's required to take the hotplug rwsem early in the
    call chain and establish a proper lock order.

    After quite some analysis and going down the wrong road severa times the
    following lock order has been chosen:

    kprobe_mutex -> cpus_rwsem -> jump_label_mutex -> text_mutex

    For kprobes which hook on an ftrace function trace point, it's required to
    drop cpus_rwsem before calling into the ftrace code to avoid a deadlock on
    the func_hash->regex_lock.

    [ Steven: Ftrace interaction fixes ]

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Steven Rostedt
    Signed-off-by: Thomas Gleixner
    Acked-by: Ingo Molnar
    Acked-by: Masami Hiramatsu
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Link: http://lkml.kernel.org/r/20170524081549.104864779@linutronix.de

    Thomas Gleixner
     

18 May, 2017

2 commits

  • Thomas discovered a bug where the kprobe trace tests had a race
    condition where the kprobe_optimizer called from a delayed work queue
    that does the optimizing and "unoptimizing" of a kprobe, can try to
    modify the text after it has been freed by the init code.

    The kprobe trace selftest is a special case, and Thomas and myself
    investigated to see if there's a chance that this could also be a bug
    with module unloading, as the code is not obvious to how it handles
    this. After adding lots of printks, I figured it out. Thomas suggested
    that this should be commented so that others will not have to go
    through this exercise again.

    Link: http://lkml.kernel.org/r/20170516145835.3827d3aa@gandalf.local.home

    Acked-by: Masami Hiramatsu
    Suggested-by: Thomas Gleixner
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)
     
  • Enabling the tracer selftest triggers occasionally the warning in
    text_poke(), which warns when the to be modified page is not marked
    reserved.

    The reason is that the tracer selftest installs kprobes on functions marked
    __init for testing. These probes are removed after the tests, but that
    removal schedules the delayed kprobes_optimizer work, which will do the
    actual text poke. If the work is executed after the init text is freed,
    then the warning triggers. The bug can be reproduced reliably when the work
    delay is increased.

    Flush the optimizer work and wait for the optimizing/unoptimizing lists to
    become empty before returning from the kprobes tracer selftest. That
    ensures that all operations which were queued due to the probes removal
    have completed.

    Link: http://lkml.kernel.org/r/20170516094802.76a468bb@gandalf.local.home

    Signed-off-by: Thomas Gleixner
    Acked-by: Masami Hiramatsu
    Cc: stable@vger.kernel.org
    Fixes: 6274de498 ("kprobes: Support delayed unoptimizing")
    Signed-off-by: Steven Rostedt (VMware)

    Thomas Gleixner
     

06 May, 2017

1 commit

  • Pull powerpc updates from Michael Ellerman:
    "Highlights include:

    - Larger virtual address space on 64-bit server CPUs. By default we
    use a 128TB virtual address space, but a process can request access
    to the full 512TB by passing a hint to mmap().

    - Support for the new Power9 "XIVE" interrupt controller.

    - TLB flushing optimisations for the radix MMU on Power9.

    - Support for CAPI cards on Power9, using the "Coherent Accelerator
    Interface Architecture 2.0".

    - The ability to configure the mmap randomisation limits at build and
    runtime.

    - Several small fixes and cleanups to the kprobes code, as well as
    support for KPROBES_ON_FTRACE.

    - Major improvements to handling of system reset interrupts,
    correctly treating them as NMIs, giving them a dedicated stack and
    using a new hypervisor call to trigger them, all of which should
    aid debugging and robustness.

    - Many fixes and other minor enhancements.

    Thanks to: Alastair D'Silva, Alexey Kardashevskiy, Alistair Popple,
    Andrew Donnellan, Aneesh Kumar K.V, Anshuman Khandual, Anton
    Blanchard, Balbir Singh, Ben Hutchings, Benjamin Herrenschmidt,
    Bhupesh Sharma, Chris Packham, Christian Zigotzky, Christophe Leroy,
    Christophe Lombard, Daniel Axtens, David Gibson, Gautham R. Shenoy,
    Gavin Shan, Geert Uytterhoeven, Guilherme G. Piccoli, Hamish Martin,
    Hari Bathini, Kees Cook, Laurent Dufour, Madhavan Srinivasan, Mahesh J
    Salgaonkar, Mahesh Salgaonkar, Masami Hiramatsu, Matt Brown, Matthew
    R. Ochs, Michael Neuling, Naveen N. Rao, Nicholas Piggin, Oliver
    O'Halloran, Pan Xinhui, Paul Mackerras, Rashmica Gupta, Russell
    Currey, Sukadev Bhattiprolu, Thadeu Lima de Souza Cascardo, Tobin C.
    Harding, Tyrel Datwyler, Uma Krishnan, Vaibhav Jain, Vipin K Parashar,
    Yang Shi"

    * tag 'powerpc-4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (214 commits)
    powerpc/64s: Power9 has no LPCR[VRMASD] field so don't set it
    powerpc/powernv: Fix TCE kill on NVLink2
    powerpc/mm/radix: Drop support for CPUs without lockless tlbie
    powerpc/book3s/mce: Move add_taint() later in virtual mode
    powerpc/sysfs: Move #ifdef CONFIG_HOTPLUG_CPU out of the function body
    powerpc/smp: Document irq enable/disable after migrating IRQs
    powerpc/mpc52xx: Don't select user-visible RTAS_PROC
    powerpc/powernv: Document cxl dependency on special case in pnv_eeh_reset()
    powerpc/eeh: Clean up and document event handling functions
    powerpc/eeh: Avoid use after free in eeh_handle_special_event()
    cxl: Mask slice error interrupts after first occurrence
    cxl: Route eeh events to all drivers in cxl_pci_error_detected()
    cxl: Force context lock during EEH flow
    powerpc/64: Allow CONFIG_RELOCATABLE if COMPILE_TEST
    powerpc/xmon: Teach xmon oops about radix vectors
    powerpc/mm/hash: Fix off-by-one in comment about kernel contexts ids
    powerpc/pseries: Enable VFIO
    powerpc/powernv: Fix iommu table size calculation hook for small tables
    powerpc/powernv: Check kzalloc() return value in pnv_pci_table_alloc
    powerpc: Add arch/powerpc/tools directory
    ...

    Linus Torvalds
     

20 Apr, 2017

3 commits

  • commit 239aeba76409 ("perf powerpc: Fix kprobe and kretprobe handling with
    kallsyms on ppc64le") changed how we use the offset field in struct kprobe on
    ABIv2. perf now offsets from the global entry point if an offset is specified
    and otherwise chooses the local entry point.

    Fix the same in kernel for kprobe API users. We do this by extending
    kprobe_lookup_name() to accept an additional parameter to indicate the offset
    specified with the kprobe registration. If offset is 0, we return the local
    function entry and return the global entry point otherwise.

    With:
    # cd /sys/kernel/debug/tracing/
    # echo "p _do_fork" >> kprobe_events
    # echo "p _do_fork+0x10" >> kprobe_events

    before this patch:
    # cat ../kprobes/list
    c0000000000d0748 k _do_fork+0x8 [DISABLED]
    c0000000000d0758 k _do_fork+0x18 [DISABLED]
    c0000000000412b0 k kretprobe_trampoline+0x0 [OPTIMIZED]

    and after:
    # cat ../kprobes/list
    c0000000000d04c8 k _do_fork+0x8 [DISABLED]
    c0000000000d04d0 k _do_fork+0x10 [DISABLED]
    c0000000000412b0 k kretprobe_trampoline+0x0 [OPTIMIZED]

    Acked-by: Ananth N Mavinakayanahalli
    Signed-off-by: Naveen N. Rao
    Signed-off-by: Michael Ellerman

    Naveen N. Rao
     
  • The macro is now pretty long and ugly on powerpc. In the light of further
    changes needed here, convert it to a __weak variant to be over-ridden with a
    nicer looking function.

    Suggested-by: Masami Hiramatsu
    Acked-by: Masami Hiramatsu
    Signed-off-by: Naveen N. Rao
    Signed-off-by: Michael Ellerman

    Naveen N. Rao
     
  • Skip preparing optprobe if the probe is ftrace-based, since anyway, it
    must not be optimized (or already optimized by ftrace).

    Tested-by: Naveen N. Rao
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Michael Ellerman

    Masami Hiramatsu
     

16 Mar, 2017

1 commit

  • perf specifies an offset from _text and since this offset is fed
    directly into the arch-specific helper, kprobes tracer rejects
    installation of kretprobes through perf. Fix this by looking up the
    actual offset from a function for the specified sym+offset.

    Refactor and reuse existing routines to limit code duplication -- we
    repurpose kprobe_addr() for determining final kprobe address and we
    split out the function entry offset determination into a separate
    generic helper.

    Before patch:

    naveen@ubuntu:~/linux/tools/perf$ sudo ./perf probe -v do_open%return
    probe-definition(0): do_open%return
    symbol:do_open file:(null) line:0 offset:0 return:1 lazy:(null)
    0 arguments
    Looking at the vmlinux_path (8 entries long)
    Using /boot/vmlinux for symbols
    Open Debuginfo file: /boot/vmlinux
    Try to find probe point from debuginfo.
    Matched function: do_open [2d0c7ff]
    Probe point found: do_open+0
    Matched function: do_open [35d76dc]
    found inline addr: 0xc0000000004ba9c4
    Failed to find "do_open%return",
    because do_open is an inlined function and has no return point.
    An error occurred in debuginfo analysis (-22).
    Trying to use symbols.
    Opening /sys/kernel/debug/tracing//README write=0
    Opening /sys/kernel/debug/tracing//kprobe_events write=1
    Writing event: r:probe/do_open _text+4469776
    Failed to write event: Invalid argument
    Error: Failed to add events. Reason: Invalid argument (Code: -22)
    naveen@ubuntu:~/linux/tools/perf$ dmesg | tail

    [ 33.568656] Given offset is not valid for return probe.

    After patch:

    naveen@ubuntu:~/linux/tools/perf$ sudo ./perf probe -v do_open%return
    probe-definition(0): do_open%return
    symbol:do_open file:(null) line:0 offset:0 return:1 lazy:(null)
    0 arguments
    Looking at the vmlinux_path (8 entries long)
    Using /boot/vmlinux for symbols
    Open Debuginfo file: /boot/vmlinux
    Try to find probe point from debuginfo.
    Matched function: do_open [2d0c7d6]
    Probe point found: do_open+0
    Matched function: do_open [35d76b3]
    found inline addr: 0xc0000000004ba9e4
    Failed to find "do_open%return",
    because do_open is an inlined function and has no return point.
    An error occurred in debuginfo analysis (-22).
    Trying to use symbols.
    Opening /sys/kernel/debug/tracing//README write=0
    Opening /sys/kernel/debug/tracing//kprobe_events write=1
    Writing event: r:probe/do_open _text+4469808
    Writing event: r:probe/do_open_1 _text+4956344
    Added new events:
    probe:do_open (on do_open%return)
    probe:do_open_1 (on do_open%return)

    You can now use it in all perf tools, such as:

    perf record -e probe:do_open_1 -aR sleep 1

    naveen@ubuntu:~/linux/tools/perf$ sudo cat /sys/kernel/debug/kprobes/list
    c000000000041370 k kretprobe_trampoline+0x0 [OPTIMIZED]
    c0000000004ba0b8 r do_open+0x8 [DISABLED]
    c000000000443430 r do_open+0x0 [DISABLED]

    Signed-off-by: Naveen N. Rao
    Acked-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Michael Ellerman
    Cc: Steven Rostedt
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/d8cd1ef420ec22e3643ac332fdabcffc77319a42.1488961018.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     

15 Mar, 2017

1 commit

  • commit fc62d0207ae0 ("kprobes: Introduce weak variant of
    kprobe_exceptions_notify()") used the __kprobes annotation to exclude
    kprobe_exceptions_notify from being probed. Since NOKPROBE_SYMBOL() is a
    better way to do this enabling the symbol to be discovered as being
    blacklisted, change over to using NOKPROBE_SYMBOL().

    Signed-off-by: Naveen N. Rao
    Acked-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Link: http://lkml.kernel.org/r/3f25bf400da5c222cd9b10eec6ded2d6b58209f8.1488991670.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     

04 Mar, 2017

1 commit

  • kretprobes can be registered by specifying an absolute address or by
    specifying offset to a symbol. However, we need to ensure this falls at
    function entry so as to be able to determine the return address.

    Validate the same during kretprobe registration. By default, there
    should not be any offset from a function entry, as determined through a
    kallsyms_lookup(). Introduce arch_function_offset_within_entry() as a
    way for architectures to override this.

    Signed-off-by: Naveen N. Rao
    Acked-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Michael Ellerman
    Cc: Steven Rostedt
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/f1583bc4839a3862cfc2acefcc56f9c8837fa2ba.1487770934.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     

23 Feb, 2017

1 commit

  • Pull powerpc updates from Michael Ellerman:
    "Highlights include:

    - Support for direct mapped LPC on POWER9, giving Linux direct access
    to devices that may be on there such as a UART.

    - Memory hotplug support for the Power9 Radix MMU.

    - Add new AUX vectors describing the processor's cache geometry, to
    be used by glibc.

    - The ability for a guest to ask the hypervisor to resize the guest's
    hash table, and in addition support for doing so automatically when
    memory is hotplugged into/out-of the guest. This allows the hash
    table to be sized based on the current memory usage of the guest,
    rather than the maximum possible memory usage.

    - Implementation of optprobes (kprobe optimisation) for powerpc.

    In addition there's the topic branch shared with the KVM tree, which
    includes support for guests to use the Radix MMU on Power9.

    Thanks to:
    Alistair Popple, Andrew Donnellan, Aneesh Kumar K.V, Anju T, Anton
    Blanchard, Benjamin Herrenschmidt, Chris Packham, Daniel Axtens,
    Daniel Borkmann, David Gibson, Finn Thain, Gautham R. Shenoy, Gavin
    Shan, Greg Kurz, Joel Stanley, John Allen, Madhavan Srinivasan,
    Mahesh Salgaonkar, Markus Elfring, Michael Neuling, Nathan Fontenot,
    Naveen N. Rao, Nicholas Piggin, Paul Mackerras, Ravi Bangoria, Reza
    Arbab, Shailendra Singh, Vaibhav Jain, Wei Yongjun"

    * tag 'powerpc-4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (129 commits)
    powerpc/mm/radix: Skip ptesync in pte update helpers
    powerpc/mm/radix: Use ptep_get_and_clear_full when clearing pte for full mm
    powerpc/mm/radix: Update pte update sequence for pte clear case
    powerpc/mm: Update PROTFAULT handling in the page fault path
    powerpc/xmon: Fix data-breakpoint
    powerpc/mm: Fix build break with BOOK3S_64=n and MEMORY_HOTPLUG=y
    powerpc/mm: Fix build break when CMA=n && SPAPR_TCE_IOMMU=y
    powerpc/mm: Fix build break with RADIX=y & HUGETLBFS=n
    powerpc/pseries: Fix typo in parameter description
    powerpc/kprobes: Remove kprobe_exceptions_notify()
    kprobes: Introduce weak variant of kprobe_exceptions_notify()
    powerpc/ftrace: Fix confusing help text for DISABLE_MPROFILE_KERNEL
    powerpc/powernv: Fix opal_exit tracepoint opcode
    powerpc: Add a prototype for mcount() so it can be versioned
    powerpc: Drop GPL from of_node_to_nid() export to match other arches
    powerpc/kprobes: Optimize kprobe in kretprobe_trampoline()
    powerpc/kprobes: Implement Optprobes
    powerpc/kprobes: Fixes for kprobe_lookup_name() on BE
    powerpc: Add helper to check if offset is within relative branch range
    powerpc/bpf: Introduce __PPC_SH64()
    ...

    Linus Torvalds
     

10 Feb, 2017

1 commit


14 Jan, 2017

1 commit

  • Improve __kernel_text_address()/kernel_text_address() to return
    true if the given address is on a kprobe's instruction slot
    trampoline.

    This can help stacktraces to determine the address is on a
    text area or not.

    To implement this atomically in is_kprobe_*_slot(), also change
    the insn_cache page list to an RCU list.

    This changes timings a bit (it delays page freeing to the RCU garbage
    collection phase), but none of that is in the hot path.

    Note: this change can add small overhead to stack unwinders because
    it adds 2 additional checks to __kernel_text_address(). However, the
    impact should be very small, because kprobe_insn_pages list has 1 entry
    per 256 probes(on x86, on arm/arm64 it will be 1024 probes),
    and kprobe_optinsn_pages has 1 entry per 32 probes(on x86).
    In most use cases, the number of kprobe events may be less
    than 20, which means that is_kprobe_*_slot() will check just one entry.

    Tested-by: Josh Poimboeuf
    Signed-off-by: Masami Hiramatsu
    Acked-by: Peter Zijlstra
    Cc: Alexander Shishkin
    Cc: Ananth N Mavinakayanahalli
    Cc: Andrew Morton
    Cc: Andrey Konovalov
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/148388747896.6869.6354262871751682264.stgit@devbox
    [ Improved the changelog and coding style. ]
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

25 Dec, 2016

1 commit


12 Oct, 2016

1 commit

  • asm-generic headers are generic implementations for architecture specific
    code and should not be included by common code. Thus use the asm/ version
    of sections.h to get at the linker sections.

    Link: http://lkml.kernel.org/r/1473602302-6208-1-git-send-email-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Masami Hiramatsu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

04 Aug, 2015

1 commit

  • Code on the kprobe blacklist doesn't want unexpected int3
    exceptions. It probably doesn't want unexpected debug exceptions
    either. Be safe: disallow breakpoints in nokprobes code.

    On non-CONFIG_KPROBES kernels, there is no kprobe blacklist. In
    that case, disallow kernel breakpoints entirely.

    It will be particularly important to keep hw breakpoints out of the
    entry and NMI code once we move debug exceptions off the IST stack.

    Signed-off-by: Andy Lutomirski
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Linus Torvalds
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/e14b152af99640448d895e3c2a8c2d5ee19a1325.1438312874.git.luto@kernel.org
    Signed-off-by: Ingo Molnar

    Andy Lutomirski
     

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