From patchwork Mon Mar 4 22:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13581322 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-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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) Reviewed-by: Mathieu Desnoyers Tested-by: Sachin Sant --- 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); }