From patchwork Tue Mar 28 19:14:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 76230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2458979vqo; Tue, 28 Mar 2023 12:37:14 -0700 (PDT) X-Google-Smtp-Source: AKy350bUBhxTR255M8HKqGK26TPMPZbDrtHHoWKRZP+IIw1WPJdZ3FB04iQ3BpUTzv7dPZT6Gu7G X-Received: by 2002:a17:906:4ed4:b0:878:61d8:d7c2 with SMTP id i20-20020a1709064ed400b0087861d8d7c2mr18723324ejv.39.1680032234430; Tue, 28 Mar 2023 12:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680032234; cv=none; d=google.com; s=arc-20160816; b=s37ECuUuS4zJJC0NrRcgOBmsYPaZQrr10HzffLSTKtJiRiKdlE4L+VBR7s6or8V1Sa XAbffPrbwvG18igym0jGqi06nTgi7py/wRWm2idm4STyuVHkENN2vDQCySSFEOgmdiLN gfvDpNBun2yknwFNUXQSqC891xfC7aFgGgP/8V0FWEOwgFMg6YXnbVro9bVyChsHw4dF LFBFvpj6jVSNTFrPNu8ZlAKh4FM83WN2kZSUQuLAp5bAwieIjYpxEBoAtKpm8ph+fQ69 xR3NONcIaIhJaH/JPXpTmaEyUqBsltD8IYeg7S4UNjIKqM9c+CopcCb0gJCCZq3zuBw5 fN8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=o67guexOczJ53jryjf5uC8KqS5hcj3qtngsvgeQpKFs=; b=Y2MDOd2uuhWlNlJdoIBf9OWnntRN9++TAHBHA5hXobJt0atSq63lsDeLA1LjDL75Cn uAfKCffbWGiVz2tvxgTmwNmDa+xd9+eO15x+5QY9iPmHJ7CoUqe/FJ6bqgVFHd0fJsFD 0JC5bbctEsAT0Oe34azpClhWvzCahIc2jyc6e9dZtMLWqMAQjRlVKUezFKnsAGRD4zdu ilKDXvot41ymg6KmPeNn0X4ZQo8yOXSzNvWNcUaPVuC0kXOo+l4rohcLrRgypgmalcVC j37hog+i+2YR5w5BBgjx9Y2X1XqeqK7cTs/5MjK+Hn4EO4SB1v27vNNrzyGPnUaxUO7/ 4lSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a170906258d00b0092c786a16acsi28896170ejb.717.2023.03.28.12.36.48; Tue, 28 Mar 2023 12:37:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbjC1TOW (ORCPT + 99 others); Tue, 28 Mar 2023 15:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbjC1TOV (ORCPT ); Tue, 28 Mar 2023 15:14:21 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41AAB2D72; Tue, 28 Mar 2023 12:14:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 5F5E0CE1EAB; Tue, 28 Mar 2023 19:14:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDADFC433D2; Tue, 28 Mar 2023 19:14:14 +0000 (UTC) Date: Tue, 28 Mar 2023 15:14:13 -0400 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mark Rutland , Beau Belgrave Subject: [PATCH] tracing/user_events: Use print_format_fields() for trace output Message-ID: <20230328151413.4770b8d7@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761641480225868064?= X-GMAIL-MSGID: =?utf-8?q?1761641480225868064?= From: "Steven Rostedt (Google)" Currently, user events are shown using the "hex" output for "safety" reasons as one cannot trust user events behaving nicely. But the hex output is not the only utility for safe outputting of trace events. The print_event_fields() is just as safe and gives user readable output. Before: example-839 [001] ..... 43.222244: 00000000: b1 06 00 00 47 03 00 00 00 00 00 00 ....G....... example-839 [001] ..... 43.564433: 00000000: b1 06 00 00 47 03 00 00 01 00 00 00 ....G....... example-839 [001] ..... 43.763917: 00000000: b1 06 00 00 47 03 00 00 02 00 00 00 ....G....... example-839 [001] ..... 43.967929: 00000000: b1 06 00 00 47 03 00 00 03 00 00 00 ....G....... After: example-837 [006] ..... 55.739249: test: count=0x0 (0) example-837 [006] ..... 111.104784: test: count=0x1 (1) example-837 [006] ..... 111.268444: test: count=0x2 (2) example-837 [006] ..... 111.416533: test: count=0x3 (3) example-837 [006] ..... 111.542859: test: count=0x4 (4) Signed-off-by: Steven Rostedt (Google) --- This depends on: https://lore.kernel.org/linux-trace-kernel/20230328145156.497651be@gandalf.local.home/ kernel/trace/trace_events_user.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 11922f7cf496..b8fb67448e00 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -22,8 +22,9 @@ #include #include #include -#include "trace.h" #include "trace_dynevent.h" +#include "trace_output.h" +#include "trace.h" #define USER_EVENTS_PREFIX_LEN (sizeof(USER_EVENTS_PREFIX)-1) @@ -1198,11 +1199,7 @@ static enum print_line_t user_event_print_trace(struct trace_iterator *iter, int flags, struct trace_event *event) { - /* Unsafe to try to decode user provided print_fmt, use hex */ - trace_print_hex_dump_seq(&iter->seq, "", DUMP_PREFIX_OFFSET, 16, - 1, iter->ent, iter->ent_size, true); - - return trace_handle_return(&iter->seq); + return print_event_fields(iter, event); } static struct trace_event_functions user_event_funcs = {