1. 21 Aug, 2022 4 commits
    • Steven Rostedt (Google)'s avatar
      tracing/eprobes: Do not allow eprobes to use $stack, or % for regs · 2673c60e
      Steven Rostedt (Google) authored
      While playing with event probes (eprobes), I tried to see what would
      happen if I attempted to retrieve the instruction pointer (%rip) knowing
      that event probes do not use pt_regs. The result was:
      
       BUG: kernel NULL pointer dereference, address: 0000000000000024
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
       PGD 0 P4D 0
       Oops: 0000 [#1] PREEMPT SMP PTI
       CPU: 1 PID: 1847 Comm: trace-cmd Not tainted 5.19.0-rc5-test+ #309
       Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01
      v03.03 07/14/2016
       RIP: 0010:get_event_field.isra.0+0x0/0x50
       Code: ff 48 c7 c7 c0 8f 74 a1 e8 3d 8b f5 ff e8 88 09 f6 ff 4c 89 e7 e8
      50 6a 13 00 48 89 ef 5b 5d 41 5c 41 5d e9 42 6a 13 00 66 90 <48> 63 47 24
      8b 57 2c 48 01 c6 8b 47 28 83 f8 02 74 0e 83 f8 04 74
       RSP: 0018:ffff916c394bbaf0 EFLAGS: 00010086
       RAX: ffff916c854041d8 RBX: ffff916c8d9fbf50 RCX: ffff916c255d2000
       RDX: 0000000000000000 RSI: ffff916c255d2008 RDI: 0000000000000000
       RBP: 0000000000000000 R08: ffff916c3a2a0c08 R09: ffff916c394bbda8
       R10: 0000000000000000 R11: 0000000000000000 R12: ffff916c854041d8
       R13: ffff916c854041b0 R14: 0000000000000000 R15: 0000000000000000
       FS:  0000000000000000(0000) GS:ffff916c9ea40000(0000)
      knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000024 CR3: 000000011b60a002 CR4: 00000000001706e0
       Call Trace:
        <TASK>
        get_eprobe_size+0xb4/0x640
        ? __mod_node_page_state+0x72/0xc0
        __eprobe_trace_func+0x59/0x1a0
        ? __mod_lruvec_page_state+0xaa/0x1b0
        ? page_remove_file_rmap+0x14/0x230
        ? page_remove_rmap+0xda/0x170
        event_triggers_call+0x52/0xe0
        trace_event_buffer_commit+0x18f/0x240
        trace_event_raw_event_sched_wakeup_template+0x7a/0xb0
        try_to_wake_up+0x260/0x4c0
        __wake_up_common+0x80/0x180
        __wake_up_common_lock+0x7c/0xc0
        do_notify_parent+0x1c9/0x2a0
        exit_notify+0x1a9/0x220
        do_exit+0x2ba/0x450
        do_group_exit+0x2d/0x90
        __x64_sys_exit_group+0x14/0x20
        do_syscall_64+0x3b/0x90
        entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Obviously this is not the desired result.
      
      Move the testing for TPARG_FL_TPOINT which is only used for event probes
      to the top of the "$" variable check, as all the other variables are not
      used for event probes. Also add a check in the register parsing "%" to
      fail if an event probe is used.
      
      Link: https://lkml.kernel.org/r/20220820134400.564426983@goodmis.org
      
      Cc: stable@vger.kernel.org
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
      Cc: Tom Zanussi <zanussi@kernel.org>
      Fixes: 7491e2c4 ("tracing: Add a probe that attaches to trace events")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      2673c60e
    • Yang Jihong's avatar
      ftrace: Fix NULL pointer dereference in is_ftrace_trampoline when ftrace is dead · c3b0f72e
      Yang Jihong authored
      ftrace_startup does not remove ops from ftrace_ops_list when
      ftrace_startup_enable fails:
      
      register_ftrace_function
        ftrace_startup
          __register_ftrace_function
            ...
            add_ftrace_ops(&ftrace_ops_list, ops)
            ...
          ...
          ftrace_startup_enable // if ftrace failed to modify, ftrace_disabled is set to 1
          ...
        return 0 // ops is in the ftrace_ops_list.
      
      When ftrace_disabled = 1, unregister_ftrace_function simply returns without doing anything:
      unregister_ftrace_function
        ftrace_shutdown
          if (unlikely(ftrace_disabled))
                  return -ENODEV;  // return here, __unregister_ftrace_function is not executed,
                                   // as a result, ops is still in the ftrace_ops_list
          __unregister_ftrace_function
          ...
      
      If ops is dynamically allocated, it will be free later, in this case,
      is_ftrace_trampoline accesses NULL pointer:
      
      is_ftrace_trampoline
        ftrace_ops_trampoline
          do_for_each_ftrace_op(op, ftrace_ops_list) // OOPS! op may be NULL!
      
      Syzkaller reports as follows:
      [ 1203.506103] BUG: kernel NULL pointer dereference, address: 000000000000010b
      [ 1203.508039] #PF: supervisor read access in kernel mode
      [ 1203.508798] #PF: error_code(0x0000) - not-present page
      [ 1203.509558] PGD 800000011660b067 P4D 800000011660b067 PUD 130fb8067 PMD 0
      [ 1203.510560] Oops: 0000 [#1] SMP KASAN PTI
      [ 1203.511189] CPU: 6 PID: 29532 Comm: syz-executor.2 Tainted: G    B   W         5.10.0 #8
      [ 1203.512324] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      [ 1203.513895] RIP: 0010:is_ftrace_trampoline+0x26/0xb0
      [ 1203.514644] Code: ff eb d3 90 41 55 41 54 49 89 fc 55 53 e8 f2 00 fd ff 48 8b 1d 3b 35 5d 03 e8 e6 00 fd ff 48 8d bb 90 00 00 00 e8 2a 81 26 00 <48> 8b ab 90 00 00 00 48 85 ed 74 1d e8 c9 00 fd ff 48 8d bb 98 00
      [ 1203.518838] RSP: 0018:ffffc900012cf960 EFLAGS: 00010246
      [ 1203.520092] RAX: 0000000000000000 RBX: 000000000000007b RCX: ffffffff8a331866
      [ 1203.521469] RDX: 0000000000000000 RSI: 0000000000000008 RDI: 000000000000010b
      [ 1203.522583] RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffff8df18b07
      [ 1203.523550] R10: fffffbfff1be3160 R11: 0000000000000001 R12: 0000000000478399
      [ 1203.524596] R13: 0000000000000000 R14: ffff888145088000 R15: 0000000000000008
      [ 1203.525634] FS:  00007f429f5f4700(0000) GS:ffff8881daf00000(0000) knlGS:0000000000000000
      [ 1203.526801] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1203.527626] CR2: 000000000000010b CR3: 0000000170e1e001 CR4: 00000000003706e0
      [ 1203.528611] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 1203.529605] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      
      Therefore, when ftrace_startup_enable fails, we need to rollback registration
      process and remove ops from ftrace_ops_list.
      
      Link: https://lkml.kernel.org/r/20220818032659.56209-1-yangjihong1@huawei.comSuggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      c3b0f72e
    • Steven Rostedt (Google)'s avatar
      tracing/perf: Fix double put of trace event when init fails · 7249921d
      Steven Rostedt (Google) authored
      If in perf_trace_event_init(), the perf_trace_event_open() fails, then it
      will call perf_trace_event_unreg() which will not only unregister the perf
      trace event, but will also call the put() function of the tp_event.
      
      The problem here is that the trace_event_try_get_ref() is called by the
      caller of perf_trace_event_init() and if perf_trace_event_init() returns a
      failure, it will then call trace_event_put(). But since the
      perf_trace_event_unreg() already called the trace_event_put() function, it
      triggers a WARN_ON().
      
       WARNING: CPU: 1 PID: 30309 at kernel/trace/trace_dynevent.c:46 trace_event_dyn_put_ref+0x15/0x20
      
      If perf_trace_event_reg() does not call the trace_event_try_get_ref() then
      the perf_trace_event_unreg() should not be calling trace_event_put(). This
      breaks symmetry and causes bugs like these.
      
      Pull out the trace_event_put() from perf_trace_event_unreg() and call it
      in the locations that perf_trace_event_unreg() is called. This not only
      fixes this bug, but also brings back the proper symmetry of the reg/unreg
      vs get/put logic.
      
      Link: https://lore.kernel.org/all/cover.1660347763.git.kjlx@templeofstupid.com/
      Link: https://lkml.kernel.org/r/20220816192817.43d5e17f@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Fixes: 1d18538e ("tracing: Have dynamic events have a ref counter")
      Reported-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Reviewed-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Tested-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      7249921d
    • Lukas Bulwahn's avatar
      tracing: React to error return from traceprobe_parse_event_name() · d8a64313
      Lukas Bulwahn authored
      The function traceprobe_parse_event_name() may set the first two function
      arguments to a non-null value and still return -EINVAL to indicate an
      unsuccessful completion of the function. Hence, it is not sufficient to
      just check the result of the two function arguments for being not null,
      but the return value also needs to be checked.
      
      Commit 95c104c3 ("tracing: Auto generate event name when creating a
      group of events") changed the error-return-value checking of the second
      traceprobe_parse_event_name() invocation in __trace_eprobe_create() and
      removed checking the return value to jump to the error handling case.
      
      Reinstate using the return value in the error-return-value checking.
      
      Link: https://lkml.kernel.org/r/20220811071734.20700-1-lukas.bulwahn@gmail.com
      
      Fixes: 95c104c3 ("tracing: Auto generate event name when creating a group of events")
      Acked-by: default avatarLinyu Yuan <quic_linyyuan@quicinc.com>
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d8a64313
  2. 05 Aug, 2022 1 commit
  3. 02 Aug, 2022 5 commits
  4. 31 Jul, 2022 1 commit
    • Steven Rostedt (Google)'s avatar
      tracing: Use a struct alignof to determine trace event field alignment · 4c3d2f93
      Steven Rostedt (Google) authored
      alignof() gives an alignment of types as they would be as standalone
      variables. But alignment in structures might be different, and when
      building the fields of events, the alignment must be the actual
      alignment otherwise the field offsets may not match what they actually
      are.
      
      This caused trace-cmd to crash, as libtraceevent did not check if the
      field offset was bigger than the event. The write_msr and read_msr
      events on 32 bit had their fields incorrect, because it had a u64 field
      between two ints. alignof(u64) would give 8, but the u64 field was at a
      4 byte alignment.
      
      Define a macro as:
      
         ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))
      
      which gives the actual alignment of types in a structure.
      
      Link: https://lkml.kernel.org/r/20220731015928.7ab3a154@rorschach.local.home
      
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: stable@vger.kernel.org
      Fixes: 04ae87a5 ("ftrace: Rework event_create_dir()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      4c3d2f93
  5. 30 Jul, 2022 19 commits
    • Daniel Bristot de Oliveira's avatar
      rv/reactor: Add the panic reactor · e88043c0
      Daniel Bristot de Oliveira authored
      Sample reactor that panics the system when an exception is found. This
      is useful both to capture a vmcore, or to fail-safe a critical system.
      
      Link: https://lkml.kernel.org/r/729aae3aba95f35738b8f8180e626d747d1d9da2.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      e88043c0
    • Daniel Bristot de Oliveira's avatar
      rv/reactor: Add the printk reactor · 135b881e
      Daniel Bristot de Oliveira authored
      A reactor that printks the reaction message.
      
      Link: https://lkml.kernel.org/r/b65f18a7fd6dc6659a3008fd7b7392de3465d47b.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      135b881e
    • Daniel Bristot de Oliveira's avatar
      rv/monitor: Add the wwnr monitor · ccc319dc
      Daniel Bristot de Oliveira authored
      Per task wakeup while not running (wwnr) monitor.
      
      This model is broken, the reason is that a task can be running in the
      processor without being set as RUNNABLE. Think about a task about to
      sleep:
      
      1:      set_current_state(TASK_UNINTERRUPTIBLE);
      2:      schedule();
      
      And then imagine an IRQ happening in between the lines one and two,
      waking the task up. BOOM, the wakeup will happen while the task is
      running.
      
      Q: Why do we need this model, so?
      A: To test the reactors.
      
      Link: https://lkml.kernel.org/r/473c0fc39967250fdebcff8b620311c11dccad30.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ccc319dc
    • Daniel Bristot de Oliveira's avatar
      rv/monitor: Add the wip monitor · 10bde81c
      Daniel Bristot de Oliveira authored
      The wakeup in preemptive (wip) monitor verifies if the
      wakeup events always take place with preemption disabled:
      
                           |
                           |
                           v
                         #==================#
                         H    preemptive    H <+
                         #==================#  |
                           |                   |
                           | preempt_disable   | preempt_enable
                           v                   |
          sched_waking   +------------------+  |
        +--------------- |                  |  |
        |                |  non_preemptive  |  |
        +--------------> |                  | -+
                         +------------------+
      
      The wakeup event always takes place with preemption disabled because
      of the scheduler synchronization. However, because the preempt_count
      and its trace event are not atomic with regard to interrupts, some
      inconsistencies might happen.
      
      The documentation illustrates one of these cases.
      
      Link: https://lkml.kernel.org/r/c98ca678df81115fddc04921b3c79720c836b18f.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      10bde81c
    • Daniel Bristot de Oliveira's avatar
      rv/monitor: Add the wip monitor skeleton created by dot2k · 8812d212
      Daniel Bristot de Oliveira authored
      THIS CODE IS NOT LINKED TO THE MAKEFILE.
      
      This model does not compile because it lacks the instrumentation
      part, which will be added next. In the typical case, there will be
      only one patch, but it was split into two patches for educational
      purposes.
      
      This is the direct output this command line:
        $ dot2k -d tools/verification/models/wip.dot -t per_cpu
      
      Link: https://lkml.kernel.org/r/5eb7a9118917e8a814c5e49853a72fc62be0a101.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      8812d212
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add deterministic automata instrumentation documentation · b6172b51
      Daniel Bristot de Oliveira authored
      Add the da_monitor_instrumentation.rst. It describes the basics
      of RV monitor instrumentation.
      
      Link: https://lkml.kernel.org/r/0557d5c68e2fc252f2643c2cc5295a67e2b73277.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      b6172b51
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add deterministic automata monitor synthesis documentation · d57aff24
      Daniel Bristot de Oliveira authored
      Add the da_monitor_synthesis.rst introduces some concepts behind the
      Deterministic Automata (DA) monitor synthesis and interface.
      
      Link: https://lkml.kernel.org/r/7873bdb7b2e5d2bc0b2eb6ca0b324af9a0ba27a0.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d57aff24
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Add dot2k · 24bce201
      Daniel Bristot de Oliveira authored
      transform .dot file into kernel rv monitor
      
      usage: dot2k [-h] -d DOT_FILE -t MONITOR_TYPE [-n MODEL_NAME] [-D DESCRIPTION]
      
      optional arguments:
        -h, --help            show this help message and exit
        -d DOT_FILE, --dot DOT_FILE
        -t MONITOR_TYPE, --monitor_type MONITOR_TYPE
        -n MODEL_NAME, --model_name MODEL_NAME
        -D DESCRIPTION, --description DESCRIPTION
      
      Link: https://lkml.kernel.org/r/083b3ae61e5a62c1e2e5d08009baa91f82181618.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      24bce201
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add deterministic automaton documentation · 4041b9bb
      Daniel Bristot de Oliveira authored
      Add documentation about deterministic automaton and its possible
      representations (formal, graphic, .dot and C).
      
      Link: https://lkml.kernel.org/r/387edaed87630bd5eb37c4275045dfd229700aa6.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      4041b9bb
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Add dot2c · e3c9fc78
      Daniel Bristot de Oliveira authored
      dot2c is a tool that transforms an automata in the graphiviz .dot file
      into an C representation of the automata.
      
      usage: dot2c [-h] dot_file
      
      dot2c: converts a .dot file into a C structure
      
      positional arguments:
        dot_file    The dot file to be converted
      
      optional arguments:
        -h, --help  show this help message and exit
      
      Link: https://lkml.kernel.org/r/b26204ba9509c80bcda31b76cdea31ddb188cd24.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      e3c9fc78
    • Daniel Bristot de Oliveira's avatar
      Documentation/rv: Add a basic documentation · ff0aaf67
      Daniel Bristot de Oliveira authored
      Add the runtime-verification.rst document, explaining the basics of RV
      and how to use the interface.
      
      Link: https://lkml.kernel.org/r/4be7d1a88ab1e2eb0767521e1ab52a149a154bc4.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ff0aaf67
    • Daniel Bristot de Oliveira's avatar
      rv/include: Add instrumentation helper functions · cc8e71c8
      Daniel Bristot de Oliveira authored
      Instrumentation helper functions to facilitate the instrumentation of
      auto-generated RV monitors create by dot2k.
      
      Link: https://lkml.kernel.org/r/3b36c9435f9d9299beb84e5c7c46920e205bedec.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      cc8e71c8
    • Daniel Bristot de Oliveira's avatar
      rv/include: Add deterministic automata monitor definition via C macros · 79257534
      Daniel Bristot de Oliveira authored
      In Linux terms, the runtime verification monitors are encapsulated
      inside the "RV monitor" abstraction. The "RV monitor" includes a set
      of instances of the monitor (per-cpu monitor, per-task monitor, and
      so on), the helper functions that glue the monitor to the system
      reference model, and the trace output as a reaction for event parsing
      and exceptions, as depicted below:
      
      Linux  +----- RV Monitor ----------------------------------+ Formal
       Realm |                                                   |  Realm
       +-------------------+     +----------------+     +-----------------+
       |   Linux kernel    |     |     Monitor    |     |     Reference   |
       |     Tracing       |  -> |   Instance(s)  | <-  |       Model     |
       | (instrumentation) |     | (verification) |     | (specification) |
       +-------------------+     +----------------+     +-----------------+
              |                          |                       |
              |                          V                       |
              |                     +----------+                 |
              |                     | Reaction |                 |
              |                     +--+--+--+-+                 |
              |                        |  |  |                   |
              |                        |  |  +-> trace output ?  |
              +------------------------|--|----------------------+
                                       |  +----> panic ?
                                       +-------> <user-specified>
      
      Add the rv/da_monitor.h, enabling automatic code generation for the
      *Monitor Instance(s)* using C macros, and code to support it.
      
      The benefits of the usage of macro for monitor synthesis are 3-fold as it:
      
      - Reduces the code duplication;
      - Facilitates the bug fix/improvement;
      - Avoids the case of developers changing the core of the monitor code
        to manipulate the model in a (let's say) non-standard way.
      
      This initial implementation presents three different types of monitor
      instances:
      
      - DECLARE_DA_MON_GLOBAL(name, type)
      - DECLARE_DA_MON_PER_CPU(name, type)
      - DECLARE_DA_MON_PER_TASK(name, type)
      
      The first declares the functions for a global deterministic automata monitor,
      the second for monitors with per-cpu instances, and the third with per-task
      instances.
      
      Link: https://lkml.kernel.org/r/51b0bf425a281e226dfeba7401d2115d6091f84e.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      79257534
    • Daniel Bristot de Oliveira's avatar
      rv/include: Add helper functions for deterministic automata · 09ecd8b8
      Daniel Bristot de Oliveira authored
      Formally, a deterministic automaton, denoted by G, is defined as a
      quintuple:
      
        G = { X, E, f, x_0, X_m }
      
      where:
      	- X is the set of states;
      	- E is the finite set of events;
      	- x_0 is the initial state;
      	- X_m (subset of X) is the set of marked states.
      	- f : X x E -> X $ is the transition function. It defines the
      	  state transition in the occurrence of a event from E in
      	  the state X. In the special case of deterministic automata,
      	  the occurrence of the event in E in a state in X has a
      	  deterministic next state from X.
      
      An automaton can also be represented using a graphical format of
      vertices (nodes) and edges. The open-source tool Graphviz can produce
      this graphic format using the (textual) DOT language as the source code.
      
      The dot2c tool presented in this paper:
      
      De Oliveira, Daniel Bristot; Cucinotta, Tommaso; De Oliveira, Romulo
      Silva. Efficient formal verification for the Linux kernel. In:
      International Conference on Software Engineering and Formal Methods.
      Springer, Cham, 2019. p. 315-332.
      
      Translates a deterministic automaton in the DOT format into a C
      source code representation that to be used for monitoring.
      
      This header file implements helper functions to facilitate the usage
      of the C output from dot2c/k for monitoring.
      
      Link: https://lkml.kernel.org/r/563234f2bfa84b540f60cf9e39c2d9f0eea95a55.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      09ecd8b8
    • Daniel Bristot de Oliveira's avatar
      rv: Add runtime reactors interface · 04acadcb
      Daniel Bristot de Oliveira authored
      A runtime monitor can cause a reaction to the detection of an
      exception on the model's execution. By default, the monitors have
      tracing reactions, printing the monitor output via tracepoints.
      But other reactions can be added (on-demand) via this interface.
      
      The user interface resembles the kernel tracing interface and
      presents these files:
      
      "available_reactors"
        - Reading shows the available reactors, one per line.
      
         For example:
           # cat available_reactors
           nop
           panic
           printk
      
       "reacting_on"
         - It is an on/off general switch for reactors, disabling
         all reactions.
      
       "monitors/MONITOR/reactors"
         - List available reactors, with the select reaction for the given
         MONITOR inside []. The default one is the nop (no operation)
         reactor.
         - Writing the name of a reactor enables it to the given
         MONITOR.
      
         For example:
           # cat monitors/wip/reactors
           [nop]
           panic
           printk
           # echo panic > monitors/wip/reactors
           # cat monitors/wip/reactors
           nop
           [panic]
           printk
      
      Link: https://lkml.kernel.org/r/1794eb994637457bdeaa6bad0b8263d2f7eece0c.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      04acadcb
    • Daniel Bristot de Oliveira's avatar
      rv: Add Runtime Verification (RV) interface · 102227b9
      Daniel Bristot de Oliveira authored
      RV is a lightweight (yet rigorous) method that complements classical
      exhaustive verification techniques (such as model checking and
      theorem proving) with a more practical approach to complex systems.
      
      RV works by analyzing the trace of the system's actual execution,
      comparing it against a formal specification of the system behavior.
      RV can give precise information on the runtime behavior of the
      monitored system while enabling the reaction for unexpected
      events, avoiding, for example, the propagation of a failure on
      safety-critical systems.
      
      The development of this interface roots in the development of the
      paper:
      
      De Oliveira, Daniel Bristot; Cucinotta, Tommaso; De Oliveira, Romulo
      Silva. Efficient formal verification for the Linux kernel. In:
      International Conference on Software Engineering and Formal Methods.
      Springer, Cham, 2019. p. 315-332.
      
      And:
      
      De Oliveira, Daniel Bristot. Automata-based formal analysis
      and verification of the real-time Linux kernel. PhD Thesis, 2020.
      
      The RV interface resembles the tracing/ interface on purpose. The current
      path for the RV interface is /sys/kernel/tracing/rv/.
      
      It presents these files:
      
       "available_monitors"
         - List the available monitors, one per line.
      
         For example:
           # cat available_monitors
           wip
           wwnr
      
       "enabled_monitors"
         - Lists the enabled monitors, one per line;
         - Writing to it enables a given monitor;
         - Writing a monitor name with a '!' prefix disables it;
         - Truncating the file disables all enabled monitors.
      
         For example:
           # cat enabled_monitors
           # echo wip > enabled_monitors
           # echo wwnr >> enabled_monitors
           # cat enabled_monitors
           wip
           wwnr
           # echo '!wip' >> enabled_monitors
           # cat enabled_monitors
           wwnr
           # echo > enabled_monitors
           # cat enabled_monitors
           #
      
         Note that more than one monitor can be enabled concurrently.
      
       "monitoring_on"
         - It is an on/off general switcher for monitoring. Note
         that it does not disable enabled monitors or detach events,
         but stop the per-entity monitors of monitoring the events
         received from the system. It resembles the "tracing_on" switcher.
      
       "monitors/"
         Each monitor will have its one directory inside "monitors/". There
         the monitor specific files will be presented.
         The "monitors/" directory resembles the "events" directory on
         tracefs.
      
         For example:
           # cd monitors/wip/
           # ls
           desc  enable
           # cat desc
           wakeup in preemptive per-cpu testing monitor.
           # cat enable
           0
      
      For further information, see the comments in the header of
      kernel/trace/rv/rv.c from this patch.
      
      Link: https://lkml.kernel.org/r/a4bfe038f50cb047bfb343ad0e12b0e646ab308b.1659052063.git.bristot@kernel.org
      
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Gabriele Paoloni <gpaoloni@redhat.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Tao Zhou <tao.zhou@linux.dev>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      102227b9
    • Steven Rostedt (Google)'s avatar
      ftrace/x86: Add back ftrace_expected assignment · ac6c1b2c
      Steven Rostedt (Google) authored
      When a ftrace_bug happens (where ftrace fails to modify a location) it is
      helpful to have what was at that location as well as what was expected to
      be there.
      
      But with the conversion to text_poke() the variable that assigns the
      expected for debugging was dropped. Unfortunately, I noticed this when I
      needed it. Add it back.
      
      Link: https://lkml.kernel.org/r/20220726101851.069d2e70@gandalf.local.home
      
      Cc: "x86@kernel.org" <x86@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Fixes: 768ae440 ("x86/ftrace: Use text_poke()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ac6c1b2c
    • Steven Rostedt (Google)'s avatar
      tracing: Use a copy of the va_list for __assign_vstr() · 3a2dcbaf
      Steven Rostedt (Google) authored
      If an instance of tracing enables the same trace event as another
      instance, or the top level instance, or even perf, then the va_list passed
      into some tracepoints can be used more than once.
      
      As va_list can only be traversed once, this can cause issues:
      
       # cat /sys/kernel/tracing/instances/qla2xxx/trace
                   cat-56106   [012] ..... 2419873.470098: ql_dbg_log: qla2xxx [0000:05:00.0]-1054:14:  Entered (null).
                   cat-56106   [012] ..... 2419873.470101: ql_dbg_log: qla2xxx [0000:05:00.0]-1000:14:  Entered ×+<96>²Ü<98>^H.
                   cat-56106   [012] ..... 2419873.470102: ql_dbg_log: qla2xxx [0000:05:00.0]-1006:14:  Prepare to issue mbox cmd=0xde589000.
      
       # cat /sys/kernel/tracing/trace
                   cat-56106   [012] ..... 2419873.470097: ql_dbg_log: qla2xxx [0000:05:00.0]-1054:14:  Entered qla2x00_get_firmware_state.
                   cat-56106   [012] ..... 2419873.470100: ql_dbg_log: qla2xxx [0000:05:00.0]-1000:14:  Entered qla2x00_mailbox_command.
                   cat-56106   [012] ..... 2419873.470102: ql_dbg_log: qla2xxx [0000:05:00.0]-1006:14:  Prepare to issue mbox cmd=0x69.
      
      The instance version is corrupted because the top level instance iterated
      the va_list first.
      
      Use va_copy() in the __assign_vstr() macro to make sure that each trace
      event for each use case gets a fresh va_list.
      
      Link: https://lore.kernel.org/all/259d53a5-958e-6508-4e45-74dba2821242@marvell.com/
      Link: https://lkml.kernel.org/r/20220719182004.21daa83e@gandalf.local.home
      
      Fixes: 0563231f ("tracing/events: Add __vstring() and __assign_vstr() helper macros")
      Reported-by: default avatarArun Easi <aeasi@marvell.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      3a2dcbaf
    • Steven Rostedt (Google)'s avatar
      batman-adv: tracing: Use the new __vstring() helper · 9abc2918
      Steven Rostedt (Google) authored
      Instead of open coding a __dynamic_array() with a fixed length (which
      defeats the purpose of the dynamic array in the first place). Use the new
      __vstring() helper that will use a va_list and only write enough of the
      string into the ring buffer that is needed.
      
      Link: https://lkml.kernel.org/r/20220724191650.236b1355@rorschach.local.home
      
      Cc: Marek Lindner <mareklindner@neomailbox.ch>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Simon Wunderlich <sw@simonwunderlich.de>
      Cc: Antonio Quartulli <a@unstable.cc>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: b.a.t.m.a.n@lists.open-mesh.org
      Cc: netdev@vger.kernel.org
      Acked-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      9abc2918
  6. 24 Jul, 2022 9 commits
  7. 19 Jul, 2022 1 commit