Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp50009lqs; Mon, 4 Mar 2024 14:42:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXpvOJUVXvV9oWifmstzj+KRuUYP/Z3rygeEPx+yoJ4YRGd2dCyeiLFNlZYgi/KXFZWoHntGBIrere+/baExhouc2Kp5ldqKlRKTvyxrw== X-Google-Smtp-Source: AGHT+IEZKIAcTR3oTEihgos7qptfoBnBQMylCwCGGzOuqSleMZXONo9hgD5tP6nTgxrTzqLPi2tO X-Received: by 2002:a2e:bc27:0:b0:2d3:7bd:da4e with SMTP id b39-20020a2ebc27000000b002d307bdda4emr159276ljf.33.1709592129067; Mon, 04 Mar 2024 14:42:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709592129; cv=pass; d=google.com; s=arc-20160816; b=S6VH4OB+CfUIKgWyxJn57CDpJ+NQXdw3+de+KwPZ8XTjUj9qtHvvtYhNMF4bBFvXmy 6YSS7cBQrb9Iq15X1xsoDnWDzl3pQYfuDWI4rfHrn/Kh8jiTkRWOG1GlE8hgaOkvb4zc uK9FBQ/1TcQJARCjyWgfWlUp5WZrouVl7b7XkxZRrhR1gk9QYWXJ3bio5LSk7I9OD7Hf eKCrpCVnwWfPrPkWv7coNRqiNdltpjZfBtycgeE0G7Uwjmef0S5w+Ealv/XDYbMqo7Xy xpkFLKL9cMR3waHZiMzukj9gFGXhaVVvw43GDjK145CMufYZPCAjXspFsC1kspAiCBSL RqTg== 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=FW9lp7apmjy4UVCdGywWAxivFOfOoWZjbdqgpex7v5E=; fh=mELnVPxQmV5jbNRDIkZPzwHwvyJ1R2nkFEb/WVcKKJI=; b=LptHCrAqavE8lCRTea9GpF/3RQh+ZzqunP+qD02AGwLs6/gXybmhZwJTVLod/voquP rrzXlnmp/evx4Wks6tWudKJPF9P3M1uf+DZFE6Bd6x376plE6zGde/ce1wA/o4OXuxYh BP3tgE3rYMI4UkVeXocMmzJojmI2ObNVYt9zmBeU/qTt6ZA2Yd5hYP+DUgGbIVjai3h0 sj2A06s8XB9/HDLlpVnkvznAAH/abwj5t0epJ2swmrn9G6DL6UlyGBB8VP9JJfS/Zq7J Vp6wZDyJhH2dxxiV9ga1N2lTsWHpbqsVnwgSsnjNh5exec1/R0F5CsQDUkksUT1LeV3y eDqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91371-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b4-20020aa7c6c4000000b0056782db4e42si199950eds.278.2024.03.04.14.42.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 14:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91371-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C697C1F21BE0 for ; Mon, 4 Mar 2024 22:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFFB57C0A4; Mon, 4 Mar 2024 22:41:54 +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 5FA597BB0F; Mon, 4 Mar 2024 22:41:54 +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=1709592114; cv=none; b=m+FatyIrmZ9GYAXAx6wFruMP/jeAUXHUv0FbnixqTpiC2BMBx4WWTM21nqh5MZM3MAp1V5JZ6dKfm/j04LL7GUg4McdCPjgjheoFVXBUM6tAFEBIge2f3DXgHxQXN+ohnVCO28IHtnMIGpRv7YN1Iv5oO6eTTcU527qZ18VX5Bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709592114; c=relaxed/simple; bh=N86BZ3vurduX6ZYiqZPgoddJQ4lkNaFSYKU9x17lROo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=pQqzWbV4PpFbkArzaY5Z6Av/qx7Kzb6nTZq8zFmWQMdprBOywnKRU0kyBpw6xbfthbMUcHrffBd2ROAbAbrB+ZtxZ2owq+RRaASDily3QnrEcJp5I69fp9wIuw16qEDPS0S19g4/hrPkM5QaFnlFg8gKnB6OgSv6lG/+3tGQWTo= 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 2999CC433F1; Mon, 4 Mar 2024 22:41:53 +0000 (UTC) Date: Mon, 4 Mar 2024 17:43:41 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers , Linus Torvalds , Sachin Sant Subject: [PATCH] tracing: Remove precision vsnprintf() check from print event Message-ID: <20240304174341.2a561d9f@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)" This reverts 60be76eeabb3d ("tracing: Add size check when printing trace_marker output"). The only reason the precision check was added was because of a bug that miscalculated the write size of the string into the ring buffer and it truncated it removing the terminating nul byte. On reading the trace it crashed the kernel. But this was due to the bug in the code that happened during development and should never happen in practice. If anything, the precision can hide bugs where the string in the ring buffer isn't nul terminated and it will not be checked. Link: https://lore.kernel.org/all/C7E7AF1A-D30F-4D18-B8E5-AF1EF58004F5@linux.ibm.com/ Link: https://lore.kernel.org/linux-trace-kernel/20240227125706.04279ac2@gandalf.local.home Link: https://lore.kernel.org/all/20240302111244.3a1674be@gandalf.local.home/ Reported-by: Sachin Sant Fixes: 60be76eeabb3d ("tracing: Add size check when printing trace_marker output") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_output.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 3e7fa44dc2b2..d8b302d01083 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -1587,12 +1587,11 @@ 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); trace_assign_type(field, iter->ent); seq_print_ip_sym(s, field->ip, flags); - trace_seq_printf(s, ": %.*s", max, field->buf); + trace_seq_printf(s, ": %s", field->buf); return trace_handle_return(s); } @@ -1601,11 +1600,10 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, struct trace_event *event) { struct print_entry *field; - int max = iter->ent_size - offsetof(struct print_entry, buf); trace_assign_type(field, iter->ent); - trace_seq_printf(&iter->seq, "# %lx %.*s", field->ip, max, field->buf); + trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf); return trace_handle_return(&iter->seq); } -- 2.43.0