All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	"JongHyuk Kim(MalHyuk)" <malhyuk97@gmail.com>,
	Kyle Zeng <kylebot@openai.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 7.2 10/88] tracing: Reject incomplete event filter expressions
Date: Wed, 28 Oct 2026 17:59:18 +0100	[thread overview]
Message-ID: <20261028165942.356429813@linuxfoundation.org> (raw)
In-Reply-To: <20261028165942.107695352@linuxfoundation.org>

7.2-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <kylebot@openai.com>

commit 1fdc4164e488916402badddbb1f51e9380dabb91 upstream.

A non-empty expression normally finishes in predicate_parse()'s inner
loop, which resolves the pending logical operators before jumping to
finalization. If the input ends after an operator, possibly followed by
unary '!' tokens, the outer loop instead falls through with unresolved
operator state.

For example, "common_pid == 1 || common_pid == 2 &&" leaves
prog[0].target equal to -1. The second pass then reads prog[-1] before
the forward-jump check can reject it. Depending on adjacent slab
contents, it can also copy an out-of-bounds word into a branch target
that passes the forward-only check. A self-targeted perf tracepoint
counting event can reach this path through PERF_EVENT_IOC_SET_FILTER.

Reject the outer-loop fallthrough when a predicate has already been
parsed. This ensures that non-empty expressions only reach finalization
after the inner loop has resolved their operators. Keep the existing
no-filter error for input that has no predicates. Add a regression test
for trailing logical operators and unary negations.

Fixes: 80765597bc587 ("tracing: Rewrite filter logic to be simpler and faster")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261023174620.91969-1-kylebot@openai.com
Assisted-by: Codex:gpt-6-astra
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Tested-by: JongHyuk Kim(MalHyuk) <malhyuk97@gmail.com>
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c                                      |    6 ++
 tools/testing/selftests/ftrace/test.d/filter/event-filter-incomplete.tc |   24 ++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/filter/event-filter-incomplete.tc

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -595,6 +595,12 @@ predicate_parse(const char *str, int nr_
 			top--;					/* #12 */
 		}
 	}
+	/* Only the inner loop can complete a non-empty expression. */
+	if (N) {
+		ret = -EINVAL;
+		parse_error(pe, FILT_ERR_INVALID_FILTER, ptr - str);
+		goto out_free;
+	}
  out:
 	if (top != op_stack) {
 		/* Too many '(' */
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/filter/event-filter-incomplete.tc
@@ -0,0 +1,24 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: event filter - reject incomplete logical expressions
+# requires: events/sched/sched_switch/filter
+# flags: instance
+
+filter=events/sched/sched_switch/filter
+
+for base in \
+    'common_pid == 1' \
+    'common_pid == 1 || common_pid == 2' \
+    'common_pid == 1 && common_pid == 2' \
+    '!(common_pid == 1 || common_pid == 2)'
+do
+    printf '%s' "$base" > "$filter"
+    for tail in '&&' '||' '&& !' '|| !' '&& !! ' '|| !! '; do
+        if printf '%s' "$base $tail" > "$filter" 2>/dev/null; then
+            echo "Accepted incomplete filter: $base $tail"
+            exit_fail
+        fi
+    done
+done
+
+echo 0 > "$filter"



  parent reply	other threads:[~2026-10-28 17:06 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 16:59 [PATCH 7.2 00/88] 7.2.14-rc1 review Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 01/88] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks off DSQs Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 02/88] ntfs: fix race between fallocate and mmap reads Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 03/88] ntfs: take invalidate_lock in ntfs_filemap_page_mkwrite() Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 04/88] mm/damon/core: error damos_commit_quota_goal() for zero target_value Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 05/88] sched/fair: Avoid overflow in place_entity() Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 06/88] Bluetooth: L2CAP: refuse __l2cap_chan_add if chan already has conn Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 07/88] tools/dma: fix building with O= Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 08/88] tracing: Hold trace_types_lock when updating modules in persistent instances Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 09/88] tracing: Hold trace_types_lock when resetting last boot data from readers Greg Kroah-Hartman
2026-10-28 16:59 ` Greg Kroah-Hartman [this message]
2026-10-28 16:59 ` [PATCH 7.2 11/88] tracing: Save the event file instead of the compatible histogram Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 12/88] tracing: Unregister field variable histograms when the command fails Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 13/88] tracing: Fix 64-bit and signed histogram fields on 32-bit kernels Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 14/88] tracing/histograms: Verify event_call identity when updating synth_event refcount Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 15/88] tracing/syscalls: Use copy_from_user for the faultable syscall buffer Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 16/88] io-wq: order the exit bit against worker creation task work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 17/88] io_uring/waitid: own the request before clearing ->head Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 18/88] io_uring/cmd: dont leave list poison in ->hash_node Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 19/88] io_uring/wait: dont spin on a stuck overflow list Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 20/88] io_uring/io-wq: dont lose the signal that ends work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 21/88] io_uring/io-wq: dont hide a link from cancellations Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 22/88] io_uring: dont flood a cancelling task with task_work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 23/88] io_uring: dont lose the DEFER_TASKRUN wake up Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 24/88] io_uring/cancel: rearm local work wake up before sleep Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 25/88] io_uring/mpscq: disable preemption while pushing Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 26/88] io_uring/io-wq: dont go to sleep on pending work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 27/88] io_uring/io-wq: dont strand work when a worker exits Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 28/88] io_uring/io-wq: dont exit with a creation pending Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 29/88] io_uring/io-wq: let cancel find picked up hashed work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 30/88] io_uring/poll: dont lose a cancel as io-wq arms poll Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 31/88] io_uring: dont lose a cancel as io-wq parks a request Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 32/88] io_uring/cancel: dont forget that the work was running Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 33/88] io_uring/cancel: recognize "no timeout" on 32-bit Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 34/88] io_uring/cancel: let CANCEL_ALL find parked requests Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 35/88] io_uring: wake ring pollers for local task_work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 36/88] io_uring/wait: look at all CQ waiters on wake up Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 37/88] io_uring/poll: drop stale double poll entry on rearm Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 38/88] io_uring/futex: allocate private hash before waiting Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 39/88] io_uring: drop the CQE cache if a refill fails Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 40/88] io_uring: dont split 128b SQEs at the SQPOLL cap Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 41/88] io_uring/register: dont wrap 32b CQEs when resizing Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 42/88] io_uring/register: handle index wrap " Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 43/88] io_uring/register: keep 128b SQEs intact on resize Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 44/88] io_uring/fdinfo: fix CQE dump of CQE32 rings Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 45/88] io_uring/timeout: dont skip over reached sequences Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 46/88] io_uring/timeout: keep repeat count on multishot update Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 47/88] io_uring/timeout: use the right clock for ABS updates Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 48/88] io_uring/wait: no early -ETIME if min_wait finds work Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 49/88] io_uring/napi: make stale entries time out after 60s Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 50/88] io_uring/napi: dont busy poll past an expired timeout Greg Kroah-Hartman
2026-10-28 16:59 ` [PATCH 7.2 51/88] io_uring/zcrx: fix buffer offsets in areas above 4GB Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 52/88] io_uring/kbuf: handle index wrap in last buffer check Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 53/88] io_uring/sqpoll: let the thread sleep on disabled rings Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 54/88] io_uring/openclose: keep the lock in io_pipe_fixed() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 55/88] io_uring: dont pass restart error codes to userspace Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 56/88] io_uring/net: dont retry recv on uncommitted buffers Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 57/88] io_uring/timeout: no ABS update of multishot timeouts Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 58/88] io_uring/timeout: dont end a linked timeout with 1 Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 59/88] io_uring: look up the file before queueing to io-wq Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 60/88] io_uring/poll: avoid retry wakeup loss when dropping ownership Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 61/88] io_uring/timeout: dont put a sequence target behind the last flush Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 62/88] io_uring/timeout: dont flush with the sequence " Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 63/88] io_uring/timeout: dont lose a cancel as io-wq arms a timeout Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 64/88] io_uring/poll: dont loop on HUP with multiple references Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 65/88] io_uring/net: keep recv buffer select length within MAX_RW_COUNT Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 66/88] io_uring/wait: wake real-time waiters from hard interrupt context Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 67/88] io_uring/waitid: prevent cancel reference wrap Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 68/88] io_uring: end the drain when the drain request completes Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 69/88] io_uring: keep the drain active when a deferred drain request is started Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 70/88] keys: Avoid the owner account dereference in named keyring lookup Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 71/88] keys: Check the authorization payload in process keyring searches Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 72/88] keys: Protect the type name while describing a key Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 73/88] keys: make keyring indexes independent of kernel addresses Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 74/88] keys: Protect the read method check against type removal Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 75/88] KEYS: Fix key_reject_and_link() race with keyring restriction Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 76/88] KEYS: trusted: Fix blob allocation size in tpm2_key_decode() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 77/88] keys/trusted_keys: return immediately after TPM unseal failure Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 78/88] asymmetric_keys: reject trust keys without IDs Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 79/88] ftrace: Initialize modname and offset in print_rec() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 80/88] coredump: hold RCU while releasing parked threads Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 81/88] signal: only SIGKILL and the freezers interrupt a coredumping task Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 82/88] signal: dont retarget shared signals in a dying thread group Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 83/88] ptrace: refuse to change the signal mask of a user worker Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 84/88] fork: release the files of a failed fork after sched_cancel_fork() Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 85/88] exit: hang up the tty before closing the files Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 86/88] coredump: prevent TIF_NOTIFY_SIGNAL from interrupting coredumps Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 87/88] pid_namespace: prevent TIF_NOTIFY_SIGNAL from interrupting the reaper Greg Kroah-Hartman
2026-10-28 17:00 ` [PATCH 7.2 88/88] signal: allow taks to temporarily block TIF_NOTIFY_SIGNAL Greg Kroah-Hartman
2026-10-28 19:39 ` [PATCH 7.2 00/88] 7.2.14-rc1 review Brett A C Sheffield
2026-10-29  4:09 ` Peter Schneider
2026-10-29 10:08 ` Pavel Machek
2026-10-29 13:49 ` Miguel Ojeda
2026-10-29 14:17 ` Ron Economos
2026-10-29 14:43 ` SJ Park
2026-10-29 15:19 ` Shuah Khan
2026-10-29 15:57 ` Barry K. Nathan
2026-10-29 16:56 ` Florian Fainelli

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=20261028165942.356429813@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=kylebot@openai.com \
    --cc=malhyuk97@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.