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 A62A33A2E3F for ; Fri, 15 May 2026 11:45:13 +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=1778845513; cv=none; b=OHZh6ZJtKm5TjSNNhNCN3xCg225aTSlrU8euUr10YWsAisUHAf5OXXftVhEsEMchILzobiegvps9LCTlWBo+QHv6CbOY01tiyrQKx5WazsEaX2AAEbWmYEeBZ/0CaeON9kmXnNuUg+W+SxPMzEfcdBkQK/QegrySoScibh5Iijw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778845513; c=relaxed/simple; bh=0WFjDMvwJJXOYN7ORPlOT5rBVZujEfhI8m9Slxp4KzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E69TeAoudVVJEcepcL+YXFgVJqeumBRamInVFCMdNM34ixsBJwNEcv+0COnCkDRVCm+B5CtTipPhvh6bdgWMOMJQZb2q96tF5esxo5NB+tJmYXnr8aMWKl29B6pABISFr3sWIIvg0+A/iIK0GMhc3Eiz05iiXSfy3wWwGWBPfM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R8BVR/w6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R8BVR/w6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA4DBC2BCB0; Fri, 15 May 2026 11:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778845513; bh=0WFjDMvwJJXOYN7ORPlOT5rBVZujEfhI8m9Slxp4KzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R8BVR/w6ukM0kOXD2+8edHXdxehgtiNL576KEud9IR04IKx4yArlK7k6VuQux+2am +uHj8fFQUFyuNwi5rrA1/feI1PxGPuAJ10WDCTEaNouVL+RrGcJtDVhsWHXhMZYjH0 Apo6lAghZ2l+Wn0xlgwz5MrW5B0+UR5tR9SwyWnY5Dv3YEMUeQKzFhYuUeRmfHdVoV SOkpN1MUTinYq3lSJC1qkiX9cZNOsYfy+3zDNMH+HVC3CTSDJEKll8R0rMNiOeXg/S Khn/nnTgXaac+AUg+rfz9gIH0ufQr1/gYSstGW5VlId4tWz63J90lcWzCvociXL/d/ 31pZcNfphTsIA== From: Sasha Levin To: stable@vger.kernel.org Cc: Steven Rostedt , Mathieu Desnoyers , "Masami Hiramatsu (Google)" , Sasha Levin Subject: [PATCH 6.12.y] tracing/probes: Limit size of event probe to 3K Date: Fri, 15 May 2026 07:45:10 -0400 Message-ID: <20260515114510.3021593-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051225-opulently-perfume-b54e@gregkh> References: <2026051225-opulently-perfume-b54e@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- kernel/trace/trace_probe.c | 6 ++++++ kernel/trace/trace_probe.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 1b937923d118b..6d73a56c42a9d 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1501,6 +1501,12 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, 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); diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 4f54f7935d5db..3d52d3c4d4957 100644 --- 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(struct trace_event_call *event_call, 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 -- 2.53.0