Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp153958lqs; Mon, 4 Mar 2024 19:32:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxUsrsxSHLDM3wOAbSdTgggQR3wuDgwkYyyWTAZj8j8S82Z4ZGMYjrTTTyvg1Zg7mJhBXvQMRvDohEBeIvy1rr1fr9fbZOuAFAaOWDJQ== X-Google-Smtp-Source: AGHT+IGNYdYDIdyMFXn5Vk16hA+KS888ljjtxu6wArvQQgPQ1fnU2TI+6ZAYJRJ/k0wvHQ0C+7/M X-Received: by 2002:ac8:57cd:0:b0:42e:c7a8:723d with SMTP id w13-20020ac857cd000000b0042ec7a8723dmr867506qta.21.1709609573739; Mon, 04 Mar 2024 19:32:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709609573; cv=pass; d=google.com; s=arc-20160816; b=SXnYkmaYPv0Uin/henEMfi5RCfSUdUEDaswW4Nnlu366OWVP4ZoMUiLjU1L5NMXcQZ bOGRhNqmLkVscCJgOEnOIH4PXqjN+VyGkYdRA/R8rteKUU3fYm6BlHwmCbwSMjMUKP6s LUCP2/W/Foi/76kZyW0Gieie/GDw2gwGfXUXZTTAzu+t1OCcU2sI4oJZu2cpFlS4ab+A RHgnBk8ErzVOuFDPl9Uh068HHPt9MAvo0wLaOqUHqMmFT6if5ww7KT49COXYjNCklbQy IQQa/4ZnQ3gYmpwFztFKyiZuQ/d/fC6KCDjV5ZNsSSv7+GzeQbvYmYBsJKTE0R8yGOJS nc8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=JfaakldCM52ExxFFSJj7RrxZeMdny/f0/GZ8F/WFq4w=; fh=mELnVPxQmV5jbNRDIkZPzwHwvyJ1R2nkFEb/WVcKKJI=; b=ZPKwWi/n1W2xb/YAXotodQBPAfcGiKj4pkExkvzzVb+gENCggb+M8KG7oP9pnxex3p bE1Ixt6erQh/O1dFAseeZmD2eiO/Br7TujUkmX6vzsrkAL/T5z9RBzQ7jvjhjJD2v+NS J7nJgfszORUyG4phnSEIVUlYxKsVT+PY+v4HbHYgBYz6+BPpIiLXUISXTaORVwpeSrzc a/hS2DLtvMEP5IvKS11BoTdlGdjoJsFDVQWRd3F/4rKXZQYnzBGbddZkVeEAzENOikgW eLax56QOhBdirj9t0pGdDpVNTPT0zDAMjxQBB1L84cz/Merxs9Z5XnLhpr4pKFFUlfq3 MogQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91623-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91623-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id eo3-20020ad45943000000b0068fe3631946si11009878qvb.387.2024.03.04.19.32.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 19:32:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91623-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91623-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91623-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B9CB1C20DE2 for ; Tue, 5 Mar 2024 03:32:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FD28381D9; Tue, 5 Mar 2024 03:32:46 +0000 (UTC) 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 1860E2F44; Tue, 5 Mar 2024 03:32:45 +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=1709609566; cv=none; b=Np7rGY5lTwivMX9bVDpwPlf6ryIDGgZNOZKLl++6BrGZKXxmlf1ZkyFhOwkt3X8anBJBks1IDNkLi48UDRzrrk8AEUZsfaBOh7D/1RQZJ4QlyFMFPLdtqQaHaAV99IRJuZlm6OUBEmIO6O2iigIayMrNBs/JKXHucfUahYVz86Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709609566; c=relaxed/simple; bh=cX8NBhzPtSej8jgrGTppfGMMCbZxG13SiFGh+FuLuUo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=Qb5gD+2OjRWr6kTT2x4WS5pFBXjuKe6n/wK7XHUbRGoWv1BysMpOUR8w9Go+01M+uRpQIRf2YhPGhaQqYThiJBwk2ngXKoN6j+1YB7U5faPpyTGKDvPhym47UMHisuZxDXtfFjwi4BToIR9J0Xs0Ovwo+kgryCoAUmf/JGoy9g4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D14BDC43390; Tue, 5 Mar 2024 03:32:44 +0000 (UTC) Date: Mon, 4 Mar 2024 22:34:33 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers , Linus Torvalds , Sachin Sant Subject: [PATCH v2] tracing: Limit trace_marker writes to just 4K Message-ID: <20240304223433.4ba47dff@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit From: "Steven Rostedt (Google)" Limit the max print event of trace_marker to just 4K string size. This must also be less than the amount that can be held by a trace_seq along with the text that is before the output (like the task name, PID, CPU, state, etc). As trace_seq is made to handle large events (some greater than 4K). Make the max size of a trace_marker write event be 4K which is guaranteed to fit in the trace_seq buffer. Suggested-by: Mathieu Desnoyers Signed-off-by: Steven Rostedt (Google) --- Changes since v1: https://lore.kernel.org/linux-trace-kernel/20240304192710.4c99677c@gandalf.local.home/ - Just make the max limit 4K and not half of the trace_seq size. The trace_seq is already made to handle events greater than 4k. kernel/trace/trace.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8198bfc54b58..d16b95ca58a7 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -7293,6 +7293,8 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp) return 0; } +#define TRACE_MARKER_MAX_SIZE 4096 + static ssize_t tracing_mark_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *fpos) @@ -7320,6 +7322,9 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, if ((ssize_t)cnt < 0) return -EINVAL; + if (cnt > TRACE_MARKER_MAX_SIZE) + cnt = TRACE_MARKER_MAX_SIZE; + meta_size = sizeof(*entry) + 2; /* add '\0' and possible '\n' */ again: size = cnt + meta_size; @@ -7328,11 +7333,6 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, if (cnt < FAULTED_SIZE) size += FAULTED_SIZE - cnt; - if (size > TRACE_SEQ_BUFFER_SIZE) { - cnt -= size - TRACE_SEQ_BUFFER_SIZE; - goto again; - } - buffer = tr->array_buffer.buffer; event = __trace_buffer_lock_reserve(buffer, TRACE_PRINT, size, tracing_gen_ctx()); -- 2.43.0