Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1315397lqg; Sun, 3 Mar 2024 04:59:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbluQhREQZEuXRHvE7rkIcLiXhrMfAn9g5a09Y0X2ErPfqNekArS6kMJ61w/OQ4jsqO6eM+/osWRB0rTwNGo6Aq+9CjbG2OUxjeGLufw== X-Google-Smtp-Source: AGHT+IGInXZLw/7LHHbQZaeddXBlMUUZOLabshXz1u/fIrNUPcwFGDtc7bKkmC5xDzTGJALGahPr X-Received: by 2002:a05:6a00:17a0:b0:6e5:cd5c:623b with SMTP id s32-20020a056a0017a000b006e5cd5c623bmr8621456pfg.16.1709470787871; Sun, 03 Mar 2024 04:59:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709470787; cv=pass; d=google.com; s=arc-20160816; b=eeQIFKakOqYCNF+0f9XI3QFsraJU7bPLkYi9OjdSuT6PUn1dJLn8p7pNbBw2r2fD+n cCmVO4/Z03tnZ4yfnO+Dr2r3sTdewYkCPVnb/+0JTi0DhB/UYwKJ0vHGpMHYK+J8Qf6I T+Pd/mD66rsP1fXr0FJNm/RsVLr63JdviaHu1Ra8SFaXz4NOWiO82xX3wAUU1FpVEdcw 9+QgW1Vu+YMsUf9DMtkbeO4l3ZF9KZmlINOZKq2UXSMpcGBXzbUIf2YCG6hDXs+FlTU4 HW8L4GuNmqyBVQ9TEMVGREh6zhvd/mSVu6rX5ShB993Vp1C4gafRJZE73HZwHdRWnr4h mqQg== 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:references:in-reply-to:message-id :subject:cc:to:from:date; bh=y+/V+2pRdDjY0mk1KjyACwEiHnZ1qh6NE/u0tQKWZk4=; fh=Z4tsOB/IV38gOyR2qPehPYRd6/PjJOdZwylA30ksxfw=; b=zKnWn4UdDuJkllw4Bvq673REcaR8Oj+ArnUbLHQS8MQA6LkqqrSf6rEG3VG+v4AKs4 G7Wt3D56tIU29nFoeqHHa1u4wSa2Ulw1m6GuUlq0NDlIrssVOs2W+XfmuuTEqZEnTCdI 9D/Jog6sOFOSuLqwnhIZqQM7k7nuCauVY1XCU4ScpL4ixWEdDK7c8MSUnG72XQMLpIuj qw0vqOCIfVbgLWdKelV5+0eaMfST04srklhHf92fIynD/DRg0P+UXqdiHgqtf/1/jUqG XGScUJdhs7P/O7ghyWUZ/b1EczvjsuCpZYAxTvnmBXD6Zoz2zC4y4Tl3WoyQtGlptNG+ 2cAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-89739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89739-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b20-20020a056a000cd400b006e62208f56fsi215210pfv.347.2024.03.03.04.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 04:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-89739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89739-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8BD432834D8 for ; Sun, 3 Mar 2024 12:59:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 490FFC154; Sun, 3 Mar 2024 12:59:41 +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 C8F52947B for ; Sun, 3 Mar 2024 12:59:40 +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=1709470780; cv=none; b=EK8ZxWsXfBWgxzU3ycP9oe3pE8xviFMhTO/gUyMYr/2ksFVPyOFbMlYuW7tV2SMuKe9EkqFmlF+mtXFKEj2ON9PpBC06GdgNHtBSdJEPBid/i3i4yqRohqqFAJKzsiOWXvzj7k1ZuDdYC9loTAv8Z8cnH6UfRrMQimczgA6MPsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709470780; c=relaxed/simple; bh=efOaSPpHNMKkGkKPOPd5Oo42Pwvrx70v2nA/t76V7XQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oO9J5iqFYTUv3CPorFxvSqWkVkSsb/StQxf1LPjP6OcBdzQRmWkWtnwfqUf6iICPk9cfgAAjizhxTCIdHFFfg5rucjBS0PkdZ7zAHhXxJqscw0zZDvepAVuRiHsD4IYjnKun8NEGGFIih9o4LaRDzzvQET3sPNxsUBarr8G7D24= 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 74B8CC433F1; Sun, 3 Mar 2024 12:59:39 +0000 (UTC) Date: Sun, 3 Mar 2024 07:59:37 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers , Sachin Sant Subject: Re: [GIT PULL] tracing: Prevent trace_marker being bigger than unsigned short Message-ID: <20240303075937.36fc6043@rorschach.local.home> In-Reply-To: References: <20240302111244.3a1674be@gandalf.local.home> <20240302145958.05aabdd2@rorschach.local.home> <20240302154713.71e29402@rorschach.local.home> X-Mailer: Claws Mail 3.17.8 (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 On Sat, 2 Mar 2024 12:55:10 -0800 Linus Torvalds wrote: > On Sat, 2 Mar 2024 at 12:47, Steven Rostedt wrote: > > > > I'm fine with just making it 4K with a comment saying that "4K is the > > minimum page size on most archs, and to keep this consistent for crazy > > architectures like PowerPC and it's 64K pages, we hard code 4K to keep > > all architectures acting the same". > > 4k is at least a somewhat sane limit, and yes, being hw-independent is > a good idea. > > We have other strings that have that limit for similar reasons (ie PATH_MAX). > I believe I was trying to solve this wrong. The vsprintf() is called on reading of the ring buffer, and I was trying to fix it on the write side. I believe that the fix should be on the read side where the vsprintf() is called. Sachin, can you try this patch. diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 3e7fa44dc2b2..5c7962d612de 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -1588,11 +1588,20 @@ static enum print_line_t trace_print_print(struct trace_iterator *iter, struct print_entry *field; struct trace_seq *s = &iter->seq; int max = iter->ent_size - offsetof(struct print_entry, buf); + const char *p; trace_assign_type(field, iter->ent); seq_print_ip_sym(s, field->ip, flags); - trace_seq_printf(s, ": %.*s", max, field->buf); + trace_seq_puts(s, ": "); + /* Write 1K chunks at a time */ + p = field->buf; + do { + int pre = max > 1024 ? 1024 : max; + trace_seq_printf(s, "%.*s", pre, p); + max -= pre; + p += pre; + } while (max > 0); return trace_handle_return(s); } @@ -1602,10 +1611,19 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, { struct print_entry *field; int max = iter->ent_size - offsetof(struct print_entry, buf); + const char *p; trace_assign_type(field, iter->ent); - trace_seq_printf(&iter->seq, "# %lx %.*s", field->ip, max, field->buf); + trace_seq_printf(&iter->seq, "# %lx", field->ip); + /* Write 1K chunks at a time */ + p = field->buf; + do { + int pre = max > 1024 ? 1024 : max; + trace_seq_printf(&iter->seq, "%.*s", pre, p); + max -= pre; + p += pre; + } while (max > 0); return trace_handle_return(&iter->seq); }