Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp85554lqi; Wed, 6 Mar 2024 10:42:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX1sxCBppVA/7wda30bfKPbyt1xFo9RBxN9AxnOwHGQgYEPxqZjSKInTnG4e6L8cuAektcPlO4pojwodRx/cyBTQecBWNHr9NffSLTqGA== X-Google-Smtp-Source: AGHT+IFy+kt7iqrYJWQxOD9kfzkk11Q2OCkGZRKolJJ8sbMUXCir9Q+idhNtTK8927rSGRmCcsPH X-Received: by 2002:a9d:6c05:0:b0:6e4:efd6:9f82 with SMTP id f5-20020a9d6c05000000b006e4efd69f82mr5981835otq.24.1709750520454; Wed, 06 Mar 2024 10:42:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709750520; cv=pass; d=google.com; s=arc-20160816; b=nNn2lGSauFeWleQzelg+ybqKQhlpaOojZa6UvajjFpAcwRRY+pWnjZQS4t/m3H8Ujz ruxpI1ERXjwby9XKwweMjJeaq/mnVRqV/DhQsqa5xnseKRUngUlgPo5QPLN/8ojANM4x KF6+zFsM6nNN5KF1YyVhM7iP30yB3z+OL7XQ4hsMAb11So7MfoQPsaZ/bBdA9ZqrLVQ9 LFUWAk3GrewfpN3sJ0IhZpCP9ZO9RDUiimdsdZHk96xhVd/tcKEM9RGYaxoKsVVMqxar aPC/fHxpISCNnQOlptim7RPSf61unN7gKfV+Opz4gGAJFNqvPqSYqCSfSZf8L3xpqv8N 2Q3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :from:date:user-agent:message-id; bh=I1sp2jDIsQ1aKukO1xtZUBGgr89sknqox48SlogkE3U=; fh=mTYg3JJ8i2GBNLFt8qb4bgYwOyk0kmrOzICLbi6qJ1c=; b=kRtmu7pi6DUXxJ3N1gPaUqGF5FBiRNHL+lHrDmZl3VuwcYJPdAvW+zeXG/VIh/aoMm NBQYr+HpSfhdxzRwHmjScDit3+tWUarjEcuSTiEClaWC2EJPVRNfJhSJOKZnS7lBJ1i4 cByar0OH5ZmEw99QEMGO7hruTpabrmabvTNcb7bHvRjuxOKopZY8pZLtKtpvKsRsosqz 9FYDUiB1OJDqzVw29jKAEAmofRdGHQjTC98iUvVQ1m2cQYmNiHnEvq8tN528qXh4IRsm cbzbbbAJwYW6gQ+lu+khyq3oZfMZOZF+1c28HedGZ2TM2ogPKALcgu5pU9hNI5Zm72Sk Qufw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-94437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94437-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 cb4-20020a056a02070400b005dc071d13c7si12893839pgb.273.2024.03.06.10.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 10:42:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94437-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-94437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94437-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 1D19C287540 for ; Wed, 6 Mar 2024 18:42:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60AAB13E7E4; Wed, 6 Mar 2024 18:41:50 +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 BFCBF136647 for ; Wed, 6 Mar 2024 18:41:49 +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=1709750509; cv=none; b=gQNJIFDVUTrvj43jds2DwtSu0XjubyynjaFFPzQ032NPkgPrPraFodom5oNO2R05NkxaJl8/lhEA3Or+b80XQ1WsOiDZjKs20fleaBDQRzXwu7j7IJNC9BbZbW+D5h53v7H65u0hNRsn88e1LQNIUUDrnnwnH5HG3uW+JsMWSVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709750509; c=relaxed/simple; bh=rh3NBCsWYsDUflpMZYfEWR9/FWHXtIuVhRGaRqvFENo=; h=Message-ID:Date:From:To:Cc:Subject; b=dK9d0/Ab6/RBmCJh5Rd5vKVgAO5vcl9zMgV1Npg+cSOt7pdLcXoWlJdMCS1+y+ptd3pKc+XgNbkz7ne2/+EZDOqwEG/EBfxUfQilv170uRxxRXof89evFHHyc3m+pqNtbpijeIqJg0QK89Q4JFxTeRH4YPeDrrn84Jl7Eu7OKc4= 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 6365AC433C7; Wed, 6 Mar 2024 18:41:49 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rhwEw-00000000Y9E-1okx; Wed, 06 Mar 2024 13:43:42 -0500 Message-ID: <20240306184244.754263547@goodmis.org> User-Agent: quilt/0.67 Date: Wed, 06 Mar 2024 13:42:44 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-linus][PATCH 0/3] tracing: Fixes for v6.8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Tracing fixes for v6.8-rc7: - The size of a string written into trace_marker was determined by the size of the sub-buffer in the ring buffer. That size is dependent on the PAGE_SIZE of the architecture as it can be mapped into user space. But on PowerPC, where PAGE_SIZE is 64K, that made the limit of the string of writing into trace_marker 64K. One of the selftests looks at the size of the ring buffer sub-buffers and writes that plus more into the trace_marker. The write will take what it can and report back what it consumed so that the user space application (like echo) will write the rest of the string. The string is stored in the ring buffer and can be read via the "trace" or "trace_pipe" files. The reading of the ring buffer uses vsnprintf(), which uses a precision "%.*s" to make sure it only reads what is stored in the buffer, as a bug could cause the string to be non terminated. With the combination of the precision change and the PAGE_SIZE of 64K allowing huge strings to be added into the ring buffer, plus the test that would actually stress that limit, a bug was reported that the precision used was too big for "%.*s" as the string was close to 64K in size and the max precision of vsnprintf is 32K. Linus suggested not to have that precision as it could hide a bug if the string was again stored without a nul byte. Another issue that was brought up is that the trace_seq buffer is also based on PAGE_SIZE even though it is not tied to the architecture limit like the ring buffer sub-buffer is. Having it be 64K * 2 is simply just too big and wasting memory on systems with 64K page sizes. It is now hardcoded to 8K which is what all other architectures with 4K PAGE_SIZE has. Finally, the write to trace_marker is now limited to 4K as there is no reason to write larger strings into trace_marker. Steven Rostedt (Google) (3): tracing: Remove precision vsnprintf() check from print event tracing: Limit trace_seq size to just 8K and not depend on architecture PAGE_SIZE tracing: Limit trace_marker writes to just 4K ---- include/linux/trace_seq.h | 8 +++++++- kernel/trace/trace.c | 10 +++++----- kernel/trace/trace_output.c | 6 ++---- 3 files changed, 14 insertions(+), 10 deletions(-)