From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382866; b=OTwnpP0XzROOhrJ3Ie/rU3uMhCD54cuPds1IF1i3yj0naDx3NDyW/4kS8Sb1kzyM+M54 FWulHP+fbHwXgD8XS5GfR7dZXdoWpKhCknE3XbRPcdv2/tQ5CF42qCXQ2Qg/KJIl9vLPu MByMbjAs7JFB+Uu5a+Eo/fSflbTLvIQkmx06kbTBszj6oLJedkIg3WDmXxdZmHm71SZT7 V5bkBQa9KFHiIDR2Tad0qV0Tl4pH5oc2uPiOhCA2d3YzJbARvBnMRLsT0+IXH7garyFGf Xon4GTGnSRU8SNa0QXAXiH3ycAB8ltEPZyTLvNoM/droyBQhEzpeQ/FN5nMa08dgjHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382866; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=5FSutJdcX0ydLJrpIKVeYDf3v/muLLa0LWtyjXjujrc=; b=nRWbHuuR9/DntnpbizAuGFs3CTv4dcnl6PqSLcvzOtx+rkCOvVQxNWij04/PqTX6G69H IuitYiMXA0oiQp0WLYiEsYLM0DQguE77t9BI+iOFngAwZilK165XqnVnd1fPgoGYiaefY +MhBkBqxK8r4HWf4YmO5Iw7eTZf9GcMieopGO7HA0FKumNb6B1MadbaOD+irtDUcop9D5 RBZmEq3GAMOfNZ+gMXAX5KPFFLimktBv9Tt/sEgct7taSC2Xm3PjgWcx7uVNXa5SEcxwb 4i7/fuNCNQU7G/1H7n795npIP4kjsXzb18rnDDv/qp5NxdDr3dtHqaS7jB9HKh918aQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SgCQ2gQi; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7EA5606A32D; Fri, 4 Dec 2026 11:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SgCQ2gQi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 213FF1F000C2; Fri, 4 Dec 2026 11:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382865; bh=5FSutJdcX0ydLJrpIKVeYDf3v/muLLa0LWtyjXjujrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SgCQ2gQieSn5VyFPbeUmDs34HK+k483/MLsctFxu4495Ag9Whl6jz2PRfRiACRnsJ sMEfJr4aywUixUKu1BGgKIj5g4pWr7+pjvxbRgBQBIO1IM0QNysdsoKgjiAHDXnrqz dwU1h+yf231o1FszrGRjcj0z+2VyWrY4hgGH6PYs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Steven Rostedt , "Masami Hiramatsu (Google)" Subject: [PATCH 6.18 587/703] tracing/filters: Fix false success return in process_system_preds() Date: Fri, 4 Dec 2026 19:08:06 +0900 Message-ID: <20261204100643.371630540@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu (Google) commit 5d4eeee1697e63cc0010cf34910a72c0f4776e42 upstream. In process_system_preds(), "fail" was initialized to true to indicate whether any event in the subsystem successfully applied the filter. However, "fail = false;" was placed at the end of the event loop outside the error check, unconditionally clearing "fail" on every iteration even when process_preds() returned an error. As a result, if every event in the subsystem fails to match the filter (e.g., an invalid field), process_system_preds() returns 0 (success) instead of -EINVAL. Consequently, create_system_filter() considers the operation successful and silently resets the subsystem filter display to the default global filter message instead of reporting the parse error. Fix this by clearing "fail" only when at least one event filter succeeds. Consolidate the cleanup logic in fail and fail_mem by using ret initialized to -ENOMEM, setting ret to -EINVAL in fail, and falling through to fail_mem, freeing any replaced filters via delay_free_filter() if !list_empty(&filter_list->list). Cc: stable@vger.kernel.org Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster") Link: https://patch.msgid.link/179324101176.752804.17624386967710135045.stgit@devnote2 Suggested-by: Steven Rostedt Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_filter.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -2270,6 +2270,7 @@ static int process_system_preds(struct t struct event_filter *filter = NULL; struct filter_head *filter_list; bool fail = true; + int ret = -ENOMEM; int err; filter_list = kmalloc(sizeof(*filter_list), GFP_KERNEL); @@ -2296,9 +2297,10 @@ static int process_system_preds(struct t filter_disable(file); parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0); append_filter_err(tr, pe, filter); - } else + } else { event_set_filtered_flag(file); - + fail = false; + } filter_item = kzalloc(sizeof(*filter_item), GFP_KERNEL); if (!filter_item) @@ -2312,8 +2314,6 @@ static int process_system_preds(struct t filter_item->filter = event_filter(file); event_set_filter(file, filter); filter = NULL; - - fail = false; } if (fail) @@ -2328,19 +2328,18 @@ static int process_system_preds(struct t return 0; fail: /* No call succeeded */ - free_filter_list(filter_list); parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0); - return -EINVAL; + ret = -EINVAL; fail_mem: __free_filter(filter); - /* If any call succeeded, we still need to sync */ - if (!fail) + /* If any filter was replaced, we still need to sync */ + if (!list_empty(&filter_list->list)) delay_free_filter(filter_list); else free_filter_list(filter_list); - return -ENOMEM; + return ret; } static int create_filter_start(char *filter_string, bool set_str,