From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04D923FF1D8; Fri, 15 May 2026 15:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860560; cv=none; b=Bl3L6ly7HBZCj+jVrvygby7VtVhgBysNI7maIKO6h60D+vqDFIT9X7EpLZpH1ulCeQ/yfDM3E3WVG03xZnnys3FEXnAwFWQHo45lZKaEAMxsGPz/1bda2AWm7RZ5z7dKY8cx5UirlaSAEufsKXwb69BJsVMSrYTc5UePSfWy1lA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860560; c=relaxed/simple; bh=rA+yrMEU2CwQ1Hl17Flcm6tAklth4n3U7HaZ/s2/3rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DTSgWDUL5grQEt9f0aLmvZvL46tF+5wAHpK3oKWYGEb4ikx2aRyKKHMJW5+heP1DRP1pQw9EvgKIYTnoOrwYQOkF06rnQ1OT5+GTGkXH56PEeZ16Phuu/+2kJIuVcm7SqAEDyZsWZcLWU159ALG/iGLcLvOtRjc8IzFY7DbQZvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hhYiMf3e; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hhYiMf3e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C7C8C2BCB0; Fri, 15 May 2026 15:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778860559; bh=rA+yrMEU2CwQ1Hl17Flcm6tAklth4n3U7HaZ/s2/3rM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhYiMf3ezzAn471i4jXBsVMDOwZR718Sa9CdIf3pjaMj9gnfQsVSlUCArHyHNde0a +c8D6L+q0Qn/pyf7J8pJszgn17HhcU/D5JmLSqQV8F8cSMEP/+jCM+hYOfxWsbVrO9 Fn2h8+R5yVMoIgukRTqm51yvM3pvQZwqPhYV4aQU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mathieu Desnoyers , "Masami Hiramatsu (Google)" , Steven Rostedt , Sasha Levin Subject: [PATCH 6.12 135/144] tracing/probes: Limit size of event probe to 3K Date: Fri, 15 May 2026 17:49:21 +0200 Message-ID: <20260515154656.650300659@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154653.469907118@linuxfoundation.org> References: <20260515154653.469907118@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt [ Upstream commit b2aa3b4d64e460ac606f386c24e7d8a873ce6f1a ] There currently isn't a max limit an event probe can be. One could make an event greater than PAGE_SIZE, which makes the event useless because if it's bigger than the max event that can be recorded into the ring buffer, then it will never be recorded. A event probe should never need to be greater than 3K, so make that the max size. As long as the max is less than the max that can be recorded onto the ring buffer, it should be fine. Cc: stable@vger.kernel.org Cc: Mathieu Desnoyers Acked-by: Masami Hiramatsu (Google) Fixes: 93ccae7a22274 ("tracing/kprobes: Support basic types on dynamic events") Link: https://patch.msgid.link/20260428122302.706610ba@gandalf.local.home Signed-off-by: Steven Rostedt [ dropped TOO_MANY_ARGS/TOO_MANY_EARGS entries from ERRORS macro list ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_probe.c | 6 ++++++ kernel/trace/trace_probe.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1501,6 +1501,12 @@ static int traceprobe_parse_probe_arg_bo parg->offset = *size; *size += parg->type->size * (parg->count ?: 1); + if (*size > MAX_PROBE_EVENT_SIZE) { + ret = -E2BIG; + trace_probe_log_err(ctx->offset, EVENT_TOO_BIG); + goto fail; + } + if (parg->count) { len = strlen(parg->type->fmttype) + 6; parg->fmt = kmalloc(len, GFP_KERNEL); --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -36,6 +36,7 @@ #define MAX_BTF_ARGS_LEN 128 #define MAX_DENTRY_ARGS_LEN 256 #define MAX_STRING_SIZE PATH_MAX +#define MAX_PROBE_EVENT_SIZE 3072 /* Reserved field names */ #define FIELD_STRING_IP "__probe_ip" @@ -549,7 +550,8 @@ extern int traceprobe_define_arg_fields( C(NO_BTF_FIELD, "This field is not found."), \ C(BAD_BTF_TID, "Failed to get BTF type info."),\ C(BAD_TYPE4STR, "This type does not fit for string."),\ - C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"), + C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),\ + C(EVENT_TOO_BIG, "Event too big (too many fields?)"), #undef C #define C(a, b) TP_ERR_##a