Merge tag 'trace-v6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 7 Jul 2023 02:07:15 +0000 (19:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 7 Jul 2023 02:07:15 +0000 (19:07 -0700)
Pull tracing fixes from Steven Rostedt:

 - Fix bad git merge of #endif in arm64 code

   A merge of the arm64 tree caused #endif to go into the wrong place

 - Fix crash on lseek of write access to tracefs/error_log

   Opening error_log as write only, and then doing an lseek() causes a
   kernel panic, because the lseek() handle expects a "seq_file" to
   exist (which is not done on write only opens). Use tracing_lseek()
   that tests for this instead of calling the default seq lseek handler.

 - Check for negative instead of -E2BIG for error on strscpy() returns

   Instead of testing for -E2BIG from strscpy(), to be more robust,
   check for less than zero, which will make sure it catches any error
   that strscpy() may someday return.

* tag 'trace-v6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing/boot: Test strscpy() against less than zero for error
  arm64: ftrace: fix build error with CONFIG_FUNCTION_GRAPH_TRACER=n
  tracing: Fix null pointer dereference in tracing_err_log_open()

1  2 
kernel/trace/trace.c

diff --combined kernel/trace/trace.c
@@@ -199,7 -199,7 +199,7 @@@ static int boot_snapshot_index
  
  static int __init set_cmdline_ftrace(char *str)
  {
 -      strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
 +      strscpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
        default_bootup_tracer = bootup_tracer_buf;
        /* We are using ftrace early, expand it */
        ring_buffer_expanded = true;
@@@ -284,7 -284,7 +284,7 @@@ static char trace_boot_options_buf[MAX_
  
  static int __init set_trace_boot_options(char *str)
  {
 -      strlcpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
 +      strscpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
        return 1;
  }
  __setup("trace_options=", set_trace_boot_options);
@@@ -294,7 -294,7 +294,7 @@@ static char *trace_boot_clock __initdat
  
  static int __init set_trace_boot_clock(char *str)
  {
 -      strlcpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
 +      strscpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
        trace_boot_clock = trace_boot_clock_buf;
        return 1;
  }
@@@ -2546,7 -2546,7 +2546,7 @@@ static void __trace_find_cmdline(int pi
        if (map != NO_CMDLINE_MAP) {
                tpid = savedcmd->map_cmdline_to_pid[map];
                if (tpid == pid) {
 -                      strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
 +                      strscpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
                        return;
                }
        }
@@@ -5199,7 -5199,7 +5199,7 @@@ static const struct file_operations tra
        .open           = tracing_open,
        .read           = seq_read,
        .read_iter      = seq_read_iter,
 -      .splice_read    = generic_file_splice_read,
 +      .splice_read    = copy_splice_read,
        .write          = tracing_write_stub,
        .llseek         = tracing_lseek,
        .release        = tracing_release,
@@@ -5672,17 -5672,10 +5672,17 @@@ static const char readme_msg[] 
        "  uprobe_events\t\t- Create/append/remove/show the userspace dynamic events\n"
        "\t\t\t  Write into this file to define/undefine new trace events.\n"
  #endif
 -#if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS)
 +#if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS) || \
 +    defined(CONFIG_FPROBE_EVENTS)
        "\t  accepts: event-definitions (one definition per line)\n"
 +#if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS)
        "\t   Format: p[:[<group>/][<event>]] <place> [<args>]\n"
        "\t           r[maxactive][:[<group>/][<event>]] <place> [<args>]\n"
 +#endif
 +#ifdef CONFIG_FPROBE_EVENTS
 +      "\t           f[:[<group>/][<event>]] <func-name>[%return] [<args>]\n"
 +      "\t           t[:[<group>/][<event>]] <tracepoint> [<args>]\n"
 +#endif
  #ifdef CONFIG_HIST_TRIGGERS
        "\t           s:[synthetic/]<event> <field> [<field>]\n"
  #endif
        "\t     args: <name>=fetcharg[:type]\n"
        "\t fetcharg: (%<register>|$<efield>), @<address>, @<symbol>[+|-<offset>],\n"
  #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
 +#ifdef CONFIG_PROBE_EVENTS_BTF_ARGS
 +      "\t           $stack<index>, $stack, $retval, $comm, $arg<N>, <argname>\n"
 +#else
        "\t           $stack<index>, $stack, $retval, $comm, $arg<N>,\n"
 +#endif
  #else
        "\t           $stack<index>, $stack, $retval, $comm,\n"
  #endif
@@@ -8146,7 -8135,7 +8146,7 @@@ static const struct file_operations tra
        .open           = tracing_err_log_open,
        .write          = tracing_err_log_write,
        .read           = seq_read,
-       .llseek         = seq_lseek,
+       .llseek         = tracing_lseek,
        .release        = tracing_err_log_release,
  };