1. 02 Oct, 2020 1 commit
  2. 28 Sep, 2020 1 commit
    • Steven Rostedt (VMware)'s avatar
      x86: Use tracepoint_enabled() for msr tracepoints instead of open coding it · fdb46fae
      Steven Rostedt (VMware) authored
      7f47d8cc ("x86, tracing, perf: Add trace point for MSR accesses") added
      tracing of msr read and write, but because of complexity in having
      tracepoints in headers, and even more so for a core header like msr.h, not
      to mention the bloat a tracepoint adds to inline functions, a helper
      function is needed to be called from the header.
      
      Use the new tracepoint_enabled() macro in tracepoint-defs.h to test if the
      tracepoint is active before calling the helper function, instead of open
      coding the same logic, which requires knowing the internals of a tracepoint.
      
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      fdb46fae
  3. 25 Sep, 2020 3 commits
  4. 22 Sep, 2020 18 commits
  5. 19 Sep, 2020 9 commits
  6. 18 Sep, 2020 7 commits
    • Masami Hiramatsu's avatar
      kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot · 82d083ab
      Masami Hiramatsu authored
      Since kprobe_event= cmdline option allows user to put kprobes on the
      functions in initmem, kprobe has to make such probes gone after boot.
      Currently the probes on the init functions in modules will be handled
      by module callback, but the kernel init text isn't handled.
      Without this, kprobes may access non-exist text area to disable or
      remove it.
      
      Link: https://lkml.kernel.org/r/159972810544.428528.1839307531600646955.stgit@devnote2
      
      Fixes: 970988e1 ("tracing/kprobe: Add kprobe_event= boot parameter")
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      82d083ab
    • Tom Rix's avatar
      tracing: fix double free · 46bbe5c6
      Tom Rix authored
      clang static analyzer reports this problem
      
      trace_events_hist.c:3824:3: warning: Attempt to free
        released memory
          kfree(hist_data->attrs->var_defs.name[i]);
      
      In parse_var_defs() if there is a problem allocating
      var_defs.expr, the earlier var_defs.name is freed.
      This free is duplicated by free_var_defs() which frees
      the rest of the list.
      
      Because free_var_defs() has to run anyway, remove the
      second free fom parse_var_defs().
      
      Link: https://lkml.kernel.org/r/20200907135845.15804-1-trix@redhat.com
      
      Cc: stable@vger.kernel.org
      Fixes: 30350d65 ("tracing: Add variable support to hist triggers")
      Reviewed-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      46bbe5c6
    • Tobias Klauser's avatar
      ftrace: Let ftrace_enable_sysctl take a kernel pointer buffer · 54fa9ba5
      Tobias Klauser authored
      Commit 32927393 ("sysctl: pass kernel pointers to ->proc_handler")
      changed ctl_table.proc_handler to take a kernel pointer. Adjust the
      signature of ftrace_enable_sysctl to match ctl_table.proc_handler which
      fixes the following sparse warning:
      
      kernel/trace/ftrace.c:7544:43: warning: incorrect type in argument 3 (different address spaces)
      kernel/trace/ftrace.c:7544:43:    expected void *
      kernel/trace/ftrace.c:7544:43:    got void [noderef] __user *buffer
      
      Link: https://lkml.kernel.org/r/20200907093207.13540-1-tklauser@distanz.ch
      
      Fixes: 32927393 ("sysctl: pass kernel pointers to ->proc_handler")
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      54fa9ba5
    • Sebastian Andrzej Siewior's avatar
      tracing: Make the space reserved for the pid wider · 795d6379
      Sebastian Andrzej Siewior authored
      For 64bit CONFIG_BASE_SMALL=0 systems PID_MAX_LIMIT is set by default to
      4194304. During boot the kernel sets a new value based on number of CPUs
      but no lower than 32768. It is 1024 per CPU so with 128 CPUs the default
      becomes 131072 which needs six digits.
      This value can be increased during run time but must not exceed the
      initial upper limit.
      
      Systemd sometime after v241 sets it to the upper limit during boot. The
      result is that when the pid exceeds five digits, the trace output is a
      little hard to read because it is no longer properly padded (same like
      on big iron with 98+ CPUs).
      
      Increase the pid padding to seven digits.
      
      Link: https://lkml.kernel.org/r/20200904082331.dcdkrr3bkn3e4qlg@linutronix.deSigned-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      795d6379
    • Adrian Hunter's avatar
      ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms · 478ece95
      Adrian Hunter authored
      Add synchronize_rcu() after list_del_rcu() in
      ftrace_remove_trampoline_from_kallsyms() to protect readers of
      ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
      which is used when kallsyms is read.
      
      Link: https://lkml.kernel.org/r/20200901091617.31837-1-adrian.hunter@intel.com
      
      Fixes: fc0ea795 ("ftrace: Add symbols for ftrace trampolines")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      478ece95
    • Miroslav Benes's avatar
      ftrace: Free the trampoline when ftrace_startup() fails · d5e47505
      Miroslav Benes authored
      Commit fc0ea795 ("ftrace: Add symbols for ftrace trampolines")
      missed to remove ops from new ftrace_ops_trampoline_list in
      ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
      lead to BUG if such ops come from a module which may be removed.
      
      Moreover, the trampoline itself is not freed in this case.
      
      Fix it by calling ftrace_trampoline_free() during the rollback.
      
      Link: https://lkml.kernel.org/r/20200831122631.28057-1-mbenes@suse.cz
      
      Fixes: fc0ea795 ("ftrace: Add symbols for ftrace trampolines")
      Fixes: f8b8be8a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict")
      Signed-off-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      d5e47505
    • Masami Hiramatsu's avatar
      kprobes: Fix to check probe enabled before disarm_kprobe_ftrace() · 3031313e
      Masami Hiramatsu authored
      Commit 0cb2f137 ("kprobes: Fix NULL pointer dereference at
      kprobe_ftrace_handler") fixed one bug but not completely fixed yet.
      If we run a kprobe_module.tc of ftracetest, kernel showed a warning
      as below.
      
      # ./ftracetest test.d/kprobe/kprobe_module.tc
      === Ftrace unit tests ===
      [1] Kprobe dynamic event - probing module
      ...
      [   22.400215] ------------[ cut here ]------------
      [   22.400962] Failed to disarm kprobe-ftrace at trace_printk_irq_work+0x0/0x7e [trace_printk] (-2)
      [   22.402139] WARNING: CPU: 7 PID: 200 at kernel/kprobes.c:1091 __disarm_kprobe_ftrace.isra.0+0x7e/0xa0
      [   22.403358] Modules linked in: trace_printk(-)
      [   22.404028] CPU: 7 PID: 200 Comm: rmmod Not tainted 5.9.0-rc2+ #66
      [   22.404870] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
      [   22.406139] RIP: 0010:__disarm_kprobe_ftrace.isra.0+0x7e/0xa0
      [   22.406947] Code: 30 8b 03 eb c9 80 3d e5 09 1f 01 00 75 dc 49 8b 34 24 89 c2 48 c7 c7 a0 c2 05 82 89 45 e4 c6 05 cc 09 1f 01 01 e8 a9 c7 f0 ff <0f> 0b 8b 45 e4 eb b9 89 c6 48 c7 c7 70 c2 05 82 89 45 e4 e8 91 c7
      [   22.409544] RSP: 0018:ffffc90000237df0 EFLAGS: 00010286
      [   22.410385] RAX: 0000000000000000 RBX: ffffffff83066024 RCX: 0000000000000000
      [   22.411434] RDX: 0000000000000001 RSI: ffffffff810de8d3 RDI: ffffffff810de8d3
      [   22.412687] RBP: ffffc90000237e10 R08: 0000000000000001 R09: 0000000000000001
      [   22.413762] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88807c478640
      [   22.414852] R13: ffffffff8235ebc0 R14: ffffffffa00060c0 R15: 0000000000000000
      [   22.415941] FS:  00000000019d48c0(0000) GS:ffff88807d7c0000(0000) knlGS:0000000000000000
      [   22.417264] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   22.418176] CR2: 00000000005bb7e3 CR3: 0000000078f7a000 CR4: 00000000000006a0
      [   22.419309] Call Trace:
      [   22.419990]  kill_kprobe+0x94/0x160
      [   22.420652]  kprobes_module_callback+0x64/0x230
      [   22.421470]  notifier_call_chain+0x4f/0x70
      [   22.422184]  blocking_notifier_call_chain+0x49/0x70
      [   22.422979]  __x64_sys_delete_module+0x1ac/0x240
      [   22.423733]  do_syscall_64+0x38/0x50
      [   22.424366]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [   22.425176] RIP: 0033:0x4bb81d
      [   22.425741] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e0 ff ff ff f7 d8 64 89 01 48
      [   22.428726] RSP: 002b:00007ffc70fef008 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
      [   22.430169] RAX: ffffffffffffffda RBX: 00000000019d48a0 RCX: 00000000004bb81d
      [   22.431375] RDX: 0000000000000000 RSI: 0000000000000880 RDI: 00007ffc70fef028
      [   22.432543] RBP: 0000000000000880 R08: 00000000ffffffff R09: 00007ffc70fef320
      [   22.433692] R10: 0000000000656300 R11: 0000000000000246 R12: 00007ffc70fef028
      [   22.434635] R13: 0000000000000000 R14: 0000000000000002 R15: 0000000000000000
      [   22.435682] irq event stamp: 1169
      [   22.436240] hardirqs last  enabled at (1179): [<ffffffff810df542>] console_unlock+0x422/0x580
      [   22.437466] hardirqs last disabled at (1188): [<ffffffff810df19b>] console_unlock+0x7b/0x580
      [   22.438608] softirqs last  enabled at (866): [<ffffffff81c0038e>] __do_softirq+0x38e/0x490
      [   22.439637] softirqs last disabled at (859): [<ffffffff81a00f42>] asm_call_on_stack+0x12/0x20
      [   22.440690] ---[ end trace 1e7ce7e1e4567276 ]---
      [   22.472832] trace_kprobe: This probe might be able to register after target module is loaded. Continue.
      
      This is because the kill_kprobe() calls disarm_kprobe_ftrace() even
      if the given probe is not enabled. In that case, ftrace_set_filter_ip()
      fails because the given probe point is not registered to ftrace.
      
      Fix to check the given (going) probe is enabled before invoking
      disarm_kprobe_ftrace().
      
      Link: https://lkml.kernel.org/r/159888672694.1411785.5987998076694782591.stgit@devnote2
      
      Fixes: 0cb2f137 ("kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler")
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: "Naveen N . Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: David Miller <davem@davemloft.net>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Chengming Zhou <zhouchengming@bytedance.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      3031313e
  7. 13 Sep, 2020 1 commit