29 Mar, 2018

1 commit

  • commit c5d343b6b7badd1f5fe0873eff2e8d63a193e732 upstream.

    In Documentation/trace/kprobetrace.txt, it says

    @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)

    However, the parser doesn't parse minus offset correctly, since
    commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be
    unsigned") drops minus ("-") offset support for kprobe probe
    address usage.

    This fixes the traceprobe_split_symbol_offset() to parse minus
    offset again with checking the offset range, and add a minus
    offset check in kprobe probe address usage.

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

    Cc: Ingo Molnar
    Cc: Tom Zanussi
    Cc: Arnaldo Carvalho de Melo
    Cc: Ravi Bangoria
    Cc: stable@vger.kernel.org
    Fixes: 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned")
    Acked-by: Namhyung Kim
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     

01 Mar, 2017

1 commit

  • We have uses of CONFIG_UPROBE_EVENT and CONFIG_KPROBE_EVENT as
    well as CONFIG_UPROBE_EVENTS and CONFIG_KPROBE_EVENTS.

    Consistently use the plurals.

    Signed-off-by: Anton Blanchard
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: acme@kernel.org
    Cc: alexander.shishkin@linux.intel.com
    Cc: davem@davemloft.net
    Cc: sparclinux@vger.kernel.org
    Link: http://lkml.kernel.org/r/20170216060050.20866-1-anton@ozlabs.org
    Signed-off-by: Ingo Molnar

    Anton Blanchard
     

24 Aug, 2016

2 commits

  • Change kprobe/uprobe-tracer to show the arguments type-casted
    with u8/u16/u32/u64 in decimal digits instead of hexadecimal.

    To minimize compatibility issue, the arguments without type
    casting are typed by x64 (or x32 for 32bit arch) by default.

    Note: all arguments set by old perf probe without types are
    shown in decimal by default.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Steven Rostedt
    Cc: Alexander Shishkin
    Cc: Hemant Kumar
    Cc: Naohiro Aota
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/147151076135.12957.14684546093034343894.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Add x8/x16/x32/x64 for hexadecimal type casting to kprobe/uprobe event
    tracer.

    These type casts can be used for integer arguments for explicitly
    showing them in hexadecimal digits in formatted text.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Steven Rostedt
    Cc: Alexander Shishkin
    Cc: Hemant Kumar
    Cc: Naohiro Aota
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/147151067029.12957.11591314629326414783.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

20 Jun, 2016

1 commit

  • ftrace is very quick to give up on saving the task command line (see
    `trace_save_cmdline()`). The workaround for events which really care
    about the command line is to explicitly assign it as part of the entry.
    However, this doesn't work for kprobe events, as there's no
    straightforward way to get access to current->comm. Add a kprobe/uprobe
    event variable $comm which provides exactly that.

    Link: http://lkml.kernel.org/r/f59b472033b943a370f5f48d0af37698f409108f.1465435894.git.osandov@fb.com

    Acked-by: Masami Hiramatsu
    Signed-off-by: Omar Sandoval
    Signed-off-by: Steven Rostedt

    Omar Sandoval
     

23 Sep, 2015

1 commit

  • This patch makes is_good_name return bool to improve readability
    due to this particular function only using either one or zero as its
    return value.

    No functional change.

    Link: http://lkml.kernel.org/r/1442929393-4753-2-git-send-email-bywxiaobai@163.com

    Signed-off-by: Yaowei Bai
    Signed-off-by: Steven Rostedt

    Yaowei Bai
     

14 May, 2015

2 commits


15 Apr, 2015

1 commit

  • Pull tracing updates from Steven Rostedt:
    "Some clean ups and small fixes, but the biggest change is the addition
    of the TRACE_DEFINE_ENUM() macro that can be used by tracepoints.

    Tracepoints have helper functions for the TP_printk() called
    __print_symbolic() and __print_flags() that lets a numeric number be
    displayed as a a human comprehensible text. What is placed in the
    TP_printk() is also shown in the tracepoint format file such that user
    space tools like perf and trace-cmd can parse the binary data and
    express the values too. Unfortunately, the way the TRACE_EVENT()
    macro works, anything placed in the TP_printk() will be shown pretty
    much exactly as is. The problem arises when enums are used. That's
    because unlike macros, enums will not be changed into their values by
    the C pre-processor. Thus, the enum string is exported to the format
    file, and this makes it useless for user space tools.

    The TRACE_DEFINE_ENUM() solves this by converting the enum strings in
    the TP_printk() format into their number, and that is what is shown to
    user space. For example, the tracepoint tlb_flush currently has this
    in its format file:

    __print_symbolic(REC->reason,
    { TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" },
    { TLB_REMOTE_SHOOTDOWN, "remote shootdown" },
    { TLB_LOCAL_SHOOTDOWN, "local shootdown" },
    { TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" })

    After adding:

    TRACE_DEFINE_ENUM(TLB_FLUSH_ON_TASK_SWITCH);
    TRACE_DEFINE_ENUM(TLB_REMOTE_SHOOTDOWN);
    TRACE_DEFINE_ENUM(TLB_LOCAL_SHOOTDOWN);
    TRACE_DEFINE_ENUM(TLB_LOCAL_MM_SHOOTDOWN);

    Its format file will contain this:

    __print_symbolic(REC->reason,
    { 0, "flush on task switch" },
    { 1, "remote shootdown" },
    { 2, "local shootdown" },
    { 3, "local mm shootdown" })"

    * tag 'trace-v4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (27 commits)
    tracing: Add enum_map file to show enums that have been mapped
    writeback: Export enums used by tracepoint to user space
    v4l: Export enums used by tracepoints to user space
    SUNRPC: Export enums in tracepoints to user space
    mm: tracing: Export enums in tracepoints to user space
    irq/tracing: Export enums in tracepoints to user space
    f2fs: Export the enums in the tracepoints to userspace
    net/9p/tracing: Export enums in tracepoints to userspace
    x86/tlb/trace: Export enums in used by tlb_flush tracepoint
    tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM()
    tracing: Allow for modules to convert their enums to values
    tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values
    tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation
    tracing: Give system name a pointer
    brcmsmac: Move each system tracepoints to their own header
    iwlwifi: Move each system tracepoints to their own header
    mac80211: Move message tracepoints to their own header
    tracing: Add TRACE_SYSTEM_VAR to xhci-hcd
    tracing: Add TRACE_SYSTEM_VAR to kvm-s390
    tracing: Add TRACE_SYSTEM_VAR to intel-sst
    ...

    Linus Torvalds
     

25 Mar, 2015

1 commit

  • The commit that added a check for this to checkpatch says:

    "Using weak declarations can have unintended link defects. The __weak on
    the declaration causes non-weak definitions to become weak."

    In this case, when a PowerPC kernel is built with CONFIG_KPROBE_EVENT
    but not CONFIG_UPROBE_EVENT, it generates the following warning:

    WARNING: 1 bad relocations
    c0000000014f2190 R_PPC64_ADDR64 uprobes_fetch_type_table

    This is fixed by passing the fetch_table arrays to
    traceprobe_parse_probe_arg() which also means that they can never be NULL.

    Link: http://lkml.kernel.org/r/20150312165834.4482cb48@canb.auug.org.au

    Acked-by: Masami Hiramatsu
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Steven Rostedt

    Stephen Rothwell
     

04 Feb, 2015

1 commit

  • debugfs was fine for the tracing facility as a quick way to get
    an interface. Now that tracing has matured, it should separate itself
    from debugfs such that it can be mounted separately without needing
    to mount all of debugfs with it. That is, users resist using tracing
    because it requires mounting debugfs. Having tracing have its own file
    system lets users get the features of tracing without needing to bring
    in the rest of the kernel's debug infrastructure.

    Another reason for tracefs is that debubfs does not support mkdir.
    Currently, to create instances, one does a mkdir in the tracing/instance
    directory. This is implemented via a hack that forces debugfs to do
    something it is not intended on doing. By converting over to tracefs, this
    hack can be removed and mkdir can be properly implemented. This patch does
    not address this yet, but it lays the ground work for that to be done.

    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

24 Apr, 2014

1 commit

  • Use NOKPROBE_SYMBOL macro to protect functions from
    kprobes instead of __kprobes annotation in ftrace.
    This applies nokprobe_inline annotation for some cases,
    because NOKPROBE_SYMBOL() will inhibit inlining by
    referring the symbol address.

    Signed-off-by: Masami Hiramatsu
    Cc: Frederic Weisbecker
    Cc: Steven Rostedt
    Link: http://lkml.kernel.org/r/20140417081828.26341.55152.stgit@ltc230.yrl.intra.hitachi.co.jp
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

21 Feb, 2014

1 commit

  • Support multi-buffer on uprobe-based dynamic events by
    using ftrace_event_file.

    This patch is based kprobe-based dynamic events multibuffer
    support work initially, commited by Masami(commit 41a7dd420c),
    but revised as below:

    Oleg changed the kprobe-based multibuffer design from
    array-pointers of ftrace_event_file into simple list,
    so this patch also change to the list design.

    rcu_read_lock/unlock added into uprobe_trace_func/uretprobe_trace_func,
    to synchronize with ftrace_event_file list add and delete.

    Even though we allow multi-uprobes instances now,
    but TP_FLAG_PROFILE/TP_FLAG_TRACE are still mutually exclusive
    in probe_event_enable currently, this means we cannot allow
    one user is using uprobe-tracer, and another user is using
    perf-probe on same uprobe concurrently.
    (Perhaps this will be fix in future, kprobe don't have this
    limitation now)

    Link: http://lkml.kernel.org/r/1389946120-19610-4-git-send-email-namhyung@kernel.org

    Reviewed-by: Masami Hiramatsu
    Reviewed-by: Oleg Nesterov
    Cc: Ingo Molnar
    Cc: Frederic Weisbecker
    Cc: Srikar Dronamraju
    Signed-off-by: zhangwei(Jovi)
    Signed-off-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    zhangwei(Jovi)
     

04 Jan, 2014

1 commit

  • When kprobe-based dynamic event tracer is not enabled, it caused
    following build error:

    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c8dd): undefined reference to `fetch_symbol_u8'
    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c8e9): undefined reference to `fetch_symbol_u16'
    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c8f5): undefined reference to `fetch_symbol_u32'
    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c901): undefined reference to `fetch_symbol_u64'
    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c909): undefined reference to `fetch_symbol_string'
    kernel/built-in.o: In function `traceprobe_update_arg':
    (.text+0x10c913): undefined reference to `fetch_symbol_string_size'
    ...

    It was due to the fetch methods are referred from CHECK_FETCH_FUNCS
    macro and since it was only defined in trace_kprobe.c. Move NULL
    definition of such fetch functions to the header file.

    Note, it also requires CONFIG_BRANCH_PROFILING enabled to trigger
    this failure as well. This is because the "fetch_symbol_*" variables
    are referenced in a "else if" statement that will only call
    update_symbol_cache(), which is a static inline stub function
    when CONFIG_KPROBE_EVENT is not enabled. gcc is smart enough
    to optimize this "else if" out and that also removes the code that
    references the undefined variables.

    But when BRANCH_PROFILING is enabled, it fools gcc into keeping
    the if statement around and thus references the undefined symbols
    and fails to build.

    Reported-by: kbuild test robot
    Signed-off-by: Namhyung Kim
    Signed-off-by: Steven Rostedt

    Namhyung Kim
     

03 Jan, 2014

9 commits

  • Enable to fetch data from a file offset. Currently it only supports
    fetching from same binary uprobe set. It'll translate the file offset
    to a proper virtual address in the process.

    The syntax is "@+OFFSET" as it does similar to normal memory fetching
    (@ADDR) which does no address translation.

    Suggested-by: Oleg Nesterov
    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • Use separate method to fetch from memory. Move existing functions to
    trace_kprobe.c and make them static. Also add new memory fetch
    implementation for uprobes.

    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • Move existing functions to trace_kprobe.c and add NULL entries to the
    uprobes fetch type table. I don't make them static since some generic
    routines like update/free_XXX_fetch_param() require pointers to the
    functions.

    Acked-by: Oleg Nesterov
    Cc: Masami Hiramatsu
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • Use separate method to fetch from stack. Move existing functions to
    trace_kprobe.c and make them static. Also add new stack fetch
    implementation for uprobes.

    Acked-by: Oleg Nesterov
    Cc: Masami Hiramatsu
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • Use separate fetch_type_table for kprobes and uprobes. It currently
    shares all fetch methods but some of them will be implemented
    differently later.

    This is not to break build if [ku]probes is configured alone (like
    !CONFIG_KPROBE_EVENT and CONFIG_UPROBE_EVENT). So I added '__weak'
    to the table declaration so that it can be safely omitted when it
    configured out.

    Acked-by: Oleg Nesterov
    Acked-by: Masami Hiramatsu
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • Move fetch function helper macros/functions to the header file and
    make them external. This is preparation of supporting uprobe fetch
    table in next patch.

    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • The set_print_fmt() functions are implemented almost same for
    [ku]probes. Move it to a common place and get rid of the duplication.

    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • The __get_data_size() and store_trace_args() will be used by uprobes
    too. Move them to a common location.

    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     
  • There are functions that can be shared to both of kprobes and uprobes.
    Separate common data structure to struct trace_probe and use it from
    the shared functions.

    Acked-by: Masami Hiramatsu
    Acked-by: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: zhangwei(Jovi)
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim

    Namhyung Kim
     

09 Feb, 2013

1 commit

  • probe_event_enable/disable() check tu->consumer != NULL to avoid the
    wrong uprobe_register/unregister().

    We are going to kill this pointer and "struct uprobe_trace_consumer",
    so we add the new helper, is_trace_uprobe_enabled(), which can rely
    on TP_FLAG_TRACE/TP_FLAG_PROFILE instead.

    Note: the current logic doesn't look optimal, it is not clear why
    TP_FLAG_TRACE/TP_FLAG_PROFILE are mutually exclusive, we will probably
    change this later.

    Also kill the unused TP_FLAG_UPROBE.

    Signed-off-by: Oleg Nesterov
    Acked-by: Srikar Dronamraju

    Oleg Nesterov
     

07 May, 2012

2 commits

  • Implements trace_event support for uprobes. In its current form
    it can be used to put probes at a specified offset in a file and
    dump the required registers when the code flow reaches the
    probed address.

    The following example shows how to dump the instruction pointer
    and %ax a register at the probed text address. Here we are
    trying to probe zfree in /bin/zsh:

    # cd /sys/kernel/debug/tracing/
    # cat /proc/`pgrep zsh`/maps | grep /bin/zsh | grep r-xp
    00400000-0048a000 r-xp 00000000 08:03 130904 /bin/zsh
    # objdump -T /bin/zsh | grep -w zfree
    0000000000446420 g DF .text 0000000000000012 Base
    zfree # echo 'p /bin/zsh:0x46420 %ip %ax' > uprobe_events
    # cat uprobe_events
    p:uprobes/p_zsh_0x46420 /bin/zsh:0x0000000000046420
    # echo 1 > events/uprobes/enable
    # sleep 20
    # echo 0 > events/uprobes/enable
    # cat trace
    # tracer: nop
    #
    # TASK-PID CPU# TIMESTAMP FUNCTION
    # | | | | |
    zsh-24842 [006] 258544.995456: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
    zsh-24842 [007] 258545.000270: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
    zsh-24842 [002] 258545.043929: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79
    zsh-24842 [004] 258547.046129: p_zsh_0x46420: (0x446420) arg1=446421 arg2=79

    Signed-off-by: Srikar Dronamraju
    Acked-by: Steven Rostedt
    Acked-by: Masami Hiramatsu
    Cc: Linus Torvalds
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Linux-mm
    Cc: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Christoph Hellwig
    Cc: Arnaldo Carvalho de Melo
    Cc: Anton Arapov
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20120411103043.GB29437@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Srikar Dronamraju
     
  • Move parts of trace_kprobe.c that can be shared with upcoming
    trace_uprobe.c. Common code to kernel/trace/trace_probe.h and
    kernel/trace/trace_probe.c. There are no functional changes.

    Signed-off-by: Srikar Dronamraju
    Acked-by: Steven Rostedt
    Acked-by: Masami Hiramatsu
    Cc: Linus Torvalds
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Linux-mm
    Cc: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Christoph Hellwig
    Cc: Arnaldo Carvalho de Melo
    Cc: Anton Arapov
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20120409091144.8343.76218.sendpatchset@srdronam.in.ibm.com
    Signed-off-by: Ingo Molnar

    Srikar Dronamraju