mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Amit Machhiwal <amachhiw@linux.ibm.com>,
	Baek Kyu Kim <pocj8ur4in@gmail.com>,
	Breno Leitao <leitao@debian.org>,
	Brian Norris <briannorris@chromium.org>,
	Chaosheng Qu <chaosheng.qu.linux@gmail.com>,
	Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>,
	David Carlier <devnexen@gmail.com>,
	Jaewon Jung <jaewon8868@gmail.com>,
	Kyle Zeng <kylebot@openai.com>, Pengfei Li <ljdlns1987@gmail.com>,
	Vincent Donnefort <vdonnefort@google.com>,
	Vineet Gupta <vineet.gupta@linux.dev>,
	Wenwu Hou <hwenwur@gmail.com>
Subject: [PATCH 0/32] tracing: Fixes for v7.4
Date: Fri, 20 Nov 2026 13:30:03 -0500	[thread overview]
Message-ID: <20261120132901.25da22b1@gandalf.local.home> (raw)
In-Reply-To: <20261120173852.687189370@kernel.org>


[
  Hmm, looks like my script died on the cover letter (an email had an extra
  comma in it :-p) Here's what it was supposed to be.
]

tracing fixes for v7.4:

- Do not WARN when trace_rb_cpu_prepare() fails to allocate on CPU startup

  The per CPU ring buffers are allocated when a new CPU comes online. If the
  system is under memory pressure it shouldn't trigger a WARN_ON if the
  buffer fails to allocate. Switch the WARN to a pr_warn() message.

- Copy trace_marker to all instances even if one fails

  Each instance can set a flag that it wants what is written into the
  trace_marker file to be copied to its ring buffer. Currently, if one of
  the instances has tracing disabled, the copy will fail. The loop that
  copies to each ring buffer detects this failure and stops copying to the
  rest of the instances. This is not what is expected as the copy should be
  tried to all instances even if it fails on one.

- Prevent perf from using filter logic to read kernel memory

  Perf can use filtering on addresses supplied by user space system calls to
  look at kernel address space and depending on the result of the filter
  determine what was in that address. Prevent perf from this type of filter.

- Fix filter logic on zero length dynamic strings

  The string filter match expects the length passed to it to include the nul
  terminating byte. Dynamic strings may be zero in length and have no nul
  byte. Have the filter logic for this strings pass in an empty string ("")
  instead.

- Fix boot filtering on common fields of events

  The common fields (like the CPU or PID of the event) are initialized after
  boot filtering is processed. This prevents boot filters from using them.
  Initialized the common fields before processing the boot filters.

- Fix ref counting of synthetic events

  When an instance is removed, it calls clear_event_triggers() on its
  events. This function does not properly release the synthetic event ref
  counters keeping them "busy" indefinitely. Fix the function to properly
  release the reference of the synthetic events they contain.

- Reject the size of zero for histograms

  Make it an error if the user tries to create a histogram of size zero. Not
  only does it not make sense, it is invalid to call to roundup_pow_of_two()
  as it is undefined.

- Fix tail matching of filtering fixed size strings

  The filtering of the end of string (*end) does not work properly for fixed
  sized string fields. This is because it matches the end of the fixed size
  and not the string itself. That is, if a fixed string field of 16 bytes
  has "abcd" and the match is to be "cd" the compare is done to the last
  three bytes of the 16 (including '\0'), which will likely not be the "cd".

- Fix the filter match of not-equal for out of range CPU masks.

  When a compare of a cpumask is out of range, the test returns nr_cpus and
  the match function will return zero (not matched) on that. But if the
  filter has a negative value (!=) then it should be a match. Fix this by
  returning "pred->op == OP_NE" which would return true if it should be a
  negative match and false otherwise.

- Fix out-of-bounds read in unfinished filter match

  If the filter passed in is "ip ==" without a value after the conditional,
  the parsing logic will increment one passed the nul byte and read the
  memory after it, possibly reading out-of-bounds memory. Detect this case
  and return an error immediately.

- Fix false success when failing on filtering of system groups

  A filter may be placed on a system group where the filter is then applied
  to each event. This returns success if at least one event succeeds. But
  the logic in the loop of all events reset the failure condition at the end
  of each iteration meaning that it would always return success even if no
  event was successful at applying it. The only way it would fail is if the
  first event failed on a memory issue.

- Free created option descriptors on instance creation failure

  If an instance were to fail to be created after creating its options, it
  would then leak them. Clean them up on failure.

- Allocate shadow stacks inline when enabling function graph hooks

  The current method of allocating the shadow stacks used by function graph
  (and which is now the backend of kretprobes), allocates 32 stacks,
  iterates over all tasks under an RCU lock and adds the stacks to the tasks
  that do not have them yet. After it has depleted and assigned all 32
  stacks, it would break out of the loop, allocate another 32 stacks and
  repeat. Unfortunately, this meant that it would iterate all the tasks it
  had already assigned stacks to before assigning new stacks. For machines
  running 1000s of tasks, this would take an exponential time to complete.

  This logic was created when the loop of all tasks required more locking
  and allocating during the loop wasn't recommended. Instead, still allocate
  the 32 stacks outside the RCU atomic but only use them if the allocation
  of a stack with GFP_NOWAIT fails. This brings down the time to enable a
  kretprobe from over 200 seconds down to 0.92 seconds on a machine with
  400,000 tasks.

- Do not start kthread in timerlat user space mode

  Timerlat has a mode that you can assign a user space task to it. Normally
  the code would not start a kernel thread in this case, but if a CPU comes
  online, it does not check if its in user space mode and starts a kernel
  thread regardless. This triggers a WARN_ON on clean up as timerlat is not
  expecting to have a kernel thread running. Prevent kernel thread start up
  when a CPU comes on line while timerlat is in user space mode.

- Do not free user events when an event probe is attached to it

  Event probes can attach to any other event. User events are events created
  that can be controlled by user space. Event probes can attach to these
  events, but they currently do not add a reference to them when they do.
  This means that the user event can be destroyed leaving the event probe
  attached to a stale event which can cause a use-after-free bug.

  On destruction of the user event, return -EBUSY if there's a dynamic event
  attached to it. Also make it persistent so that the event can be destroyed
  once the last fd is closed for it.

- Synchronize the clearing of the copy marker flag

  The marker_copies link list contains all the instances that are to copy
  the trace_marker writes. When the flag is cleared, and the instance is
  removed from the list, wait an RCU synchronization, otherwise if the flag
  is set again, it can cause the same write to be written twice as the
  instance would be added to the end of the list and a current copy walk of
  the list would hit the same instance again.

- Use copy_from_user() and not __copy_from_user() when reading user addresses

  When a system call event reads the user space address (like reading the
  path string of an openat system call), it users __copy_from_user() which
  assumes the address has been verified. Use the copy_from_user() function
  instead to verify that the address is OK for user space to read. Note,
  this has no security concern as this data read is only visible by the
  tracing system which in turn is only visible by admins.

- Fix shadow stack marking of the function graph infrastructure

  An old implementation of the shadow stack set bit zero of the shadow stack
  frame to denote tail function calls. This is no longer the case and the
  setting of the bit can trigger a WARN_ON in some cases.

- Do not do a reader-page swap when head is on tail

  The remote ring buffer does not handle swapping the buffer when the head
  is on the tail page. Prevent it from happening.

- Fix race between reader and writer of remote ring buffer reader page

  When there's data in the buffer, the reader first checks the meta page
  counter and then reads the data on the page. But because the writer
  updates the content of the pages before updating the meta data, the reader
  receives NULL unexpectedly. Swap the checks around so that the reader
  still returns the data if there is some before checking the meta data.

  Also fix the data ordering of remote buffer page time accounting.

- Fix wrong unit used in hwlat tracer accounting

  The tr->max_latency stores nanoseconds (even though its updated from user
  space in microseconds, but its converted over). The hwlat tracer assumes
  that the tr->max_latency is in microseconds and updates it accordingly.
  This causes the output to user space to be off by 1000. Do all
  calculations in the hwlat in nanoseconds.

- Properly match filter strings that start with numbers

  The set_ftrace_fiter file can take numbers to set functions via an index
  into the file instead of having to search all tens of thousands of files
  for a match. This code is shared with the event filtering logic as well.
  But this caused some of the event filters to get confused by strings
  matching numbers and turning it into an index which did not apply to
  events.

  Have the function tracing handle indexes directly and remove that logic
  from the event filtering so that the indexing only affects the
  set_ftrace_filter file and nothing else.

- Protect the ring_buffer ioctl from concurrent readers

  The ring_buffer ioctl call that maps the ring buffer can race with
  concurrent readers. Have it take the trace_access_lock().

- Prevent user events from defining a system name

  Currently, user events is the one dynamic event that does not allow the
  API from defining its own system (all user events go into the
  "user_events" system). But nothing prevents the user from trying to create
  one. As systems are denoted with '/' to separate the system from the event
  name, the API simply takes the entire string (the '/' and all) as the
  event name and tries to create a file with it. This causes the tracefs
  file system to be corrupted.

  Have the system call fail with -EINVAL if '/' is used.

- Do not use si_mem_available() in early boot for ring_buffer allocation

  When allocating the ring buffer, the amount allocated is compared to the
  amount of memory available so that it doesn't allocate too much and cause
  a system failure. It uses si_mem_available() to get an approximate amount
  of memory it can allocate. On systems with CONFIG_DEFERRED_STRUCT_PAGE_INIT
  and on early boot up, the value returned by si_mem_available() is derived
  by NR_FREE_PAGES and can under report the amount of free memory. This
  makes it nearly impossible to allocate the ring buffer and do early boot
  tracing on these systems.

  For this case, use LONG_MAX as the maximum amount available. If it
  allocates too much and crashes the system, that's on the sysadmin that
  asked for too much memory for the ring buffer on the kernel command line.

- Add notrace to event functions that use function hooks 

  A few options in the event code hooks into the ftrace function hook
  mechanism. These functions must be marked with notrace. When
  CONFIG_FUNCTION_SELF_TRACING is enabled, event functions can be traced by
  ftrace and because these functions are not marked as notrace when they are
  traced, it causes an infinite loop and the system triple faults. Normally
  this wasn't a problem because without the SELF_TRACING set, all files in
  the tracing directory are marked as notrace.

  Mark the individual functions that are used in the event code with ftrace
  as notrace so that the rest of the code can still be traced by ftrace.

- Ignore .function field modifier if the event is already a function event

  Perf can hook to the ftrace function event which is special and is marked
  as a "function" event where its fields can be filtered against function
  names. If the perf uses adds a filter to the ftrace event and adds the
  ".function" modifier (which converts the field to a function field to be
  searched with function names), the double conversion confuses the logic as
  the code for the ".function" does not work with function events (only
  normal events with unsigned long fields). This can end up with a NULL
  pointer dereference.

  If the ".function" modifier is used on a function event, simply ignore it,
  as the processing will work the same.


  git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/fixes

Head SHA1: 56ce4ed6316cae9536ea891d6686b92f1d930c00


Amit Machhiwal (1):
      ring-buffer: Do not check si_mem_available() before deferred init completes

Baek Kyu, Kim (1):
      tracing: Free tracer resources on instance creation failure

Breno Leitao (1):
      fgraph: Do not mark index 0 in every shadow stack frame

Brian Norris (2):
      tracing: Properly match strings that start with numbers
      tracing: Add tests for globbing number-based strings

Chaosheng Qu (1):
      tracing/osnoise: Don't start a kthread in timerlat user-space mode

Christian Aurich Zanettini Martins (1):
      ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate

David Carlier (4):
      tracing: Define common event fields before enabling boot events
      tracing: Drop the synthetic event ref when clearing hist triggers
      tracing/user_events: Don't free an event that a dynamic event still references
      tracing: Ignore .function on the function trace event

Jaewon Jung (2):
      tracing: Keep copying markers when one instance is stopped
      tracing: Avoid undefined shifts for zero histogram map size

Kyle Zeng (3):
      tracing: Restrict perf filters that read kernel strings
      tracing/filters: Treat zero-length dynamic strings as empty
      tracing: Validate user addresses in faultable buffer copies

Masami Hiramatsu (Google) (4):
      tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings
      tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison
      tracing/filters: Check for missing operand after operator in parse_pred()
      tracing/filters: Fix false success return in process_system_preds()

Pengfei Li (1):
      tracing: Wait for marker writers when copy_trace_marker is cleared

Steven Rostedt (3):
      fgraph: Read the task->ret_stack with a smp_load_acquire()
      tracing: Do not allow user events to add a system name
      tracing: Add notrace to event functions that hook to ftrace

Vincent Donnefort (5):
      ring-buffer: Skip remote reader page swap when on tail
      ring-buffer: Check remote reader page commit before meta entries
      ring-buffer: Order remote page commit with data and timestamp
      ring-buffer: Increment pages_read on remote ring buffer page swap
      tracing: Take trace_access_lock() in tracing_buffers_ioctl()

Vineet Gupta (2):
      fgraph: Allocate shadow stacks inline with GFP_NOWAIT
      fgraph: Use scoped_guard() for the task list walk

Wenwu Hou (1):
      tracing/hwlat: Do the latency calculations in nanoseconds

----
 kernel/trace/fgraph.c                   |  59 +++++-----
 kernel/trace/ftrace.c                   |   3 +-
 kernel/trace/ring_buffer.c              |  60 +++++++---
 kernel/trace/simple_ring_buffer.c       |  26 +++-
 kernel/trace/trace.c                    |  45 ++++---
 kernel/trace/trace.h                    |   3 +-
 kernel/trace/trace_events.c             |   8 +-
 kernel/trace/trace_events_filter.c      | 203 +++++++++++++++++++++++++++-----
 kernel/trace/trace_events_filter_test.h |  12 +-
 kernel/trace/trace_events_hist.c        |  25 ++--
 kernel/trace/trace_events_trigger.c     |   2 +
 kernel/trace/trace_events_user.c        |  12 ++
 kernel/trace/trace_hwlat.c              |  41 ++++---
 kernel/trace/trace_osnoise.c            |   8 ++
 14 files changed, 375 insertions(+), 132 deletions(-)

      parent reply	other threads:[~2026-11-20 18:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:38 Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 01/32] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 02/32] tracing: Keep copying markers when one instance is stopped Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 03/32] tracing: Restrict perf filters that read kernel strings Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 04/32] tracing/filters: Treat zero-length dynamic strings as empty Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 05/32] tracing: Define common event fields before enabling boot events Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 06/32] tracing: Drop the synthetic event ref when clearing hist triggers Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 07/32] tracing: Avoid undefined shifts for zero histogram map size Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 08/32] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 09/32] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 10/32] tracing/filters: Check for missing operand after operator in parse_pred() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 11/32] tracing/filters: Fix false success return in process_system_preds() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 12/32] tracing: Free tracer resources on instance creation failure Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 13/32] fgraph: Allocate shadow stacks inline with GFP_NOWAIT Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 14/32] fgraph: Use scoped_guard() for the task list walk Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 15/32] fgraph: Read the task->ret_stack with a smp_load_acquire() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 16/32] tracing/osnoise: Dont start a kthread in timerlat user-space mode Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 17/32] tracing/user_events: Dont free an event that a dynamic event still references Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 18/32] tracing: Wait for marker writers when copy_trace_marker is cleared Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 19/32] tracing: Validate user addresses in faultable buffer copies Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 20/32] fgraph: Do not mark index 0 in every shadow stack frame Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 21/32] ring-buffer: Skip remote reader page swap when on tail Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 22/32] ring-buffer: Check remote reader page commit before meta entries Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 23/32] ring-buffer: Order remote page commit with data and timestamp Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 24/32] ring-buffer: Increment pages_read on remote ring buffer page swap Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 25/32] tracing/hwlat: Do the latency calculations in nanoseconds Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 26/32] tracing: Properly match strings that start with numbers Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 27/32] tracing: Add tests for globbing number-based strings Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 28/32] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 29/32] tracing: Do not allow user events to add a system name Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 30/32] ring-buffer: Do not check si_mem_available() before deferred init completes Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 31/32] tracing: Add notrace to event functions that hook to ftrace Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 32/32] tracing: Ignore .function on the function trace event Steven Rostedt
2026-11-20 18:30 ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120132901.25da22b1@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=amachhiw@linux.ibm.com \
    --cc=briannorris@chromium.org \
    --cc=chaosheng.qu.linux@gmail.com \
    --cc=christian.aurichzm@gmail.com \
    --cc=devnexen@gmail.com \
    --cc=hwenwur@gmail.com \
    --cc=jaewon8868@gmail.com \
    --cc=kylebot@openai.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljdlns1987@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=pocj8ur4in@gmail.com \
    --cc=vdonnefort@google.com \
    --cc=vineet.gupta@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®