Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp150244imw; Tue, 12 Jul 2022 16:33:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQMcp23kWiAxWVgUjdWt0cL3Dc9bfgvUN9U85zlS9UMyVfIfJA9qT61a9VFvmxXEdFdNBJ X-Received: by 2002:a05:6402:2404:b0:437:d11f:b9c7 with SMTP id t4-20020a056402240400b00437d11fb9c7mr859443eda.176.1657668807218; Tue, 12 Jul 2022 16:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657668807; cv=none; d=google.com; s=arc-20160816; b=BleetEgiZx1ie5nS1OmOSenuEKcBLWOe946FVqsnzzCt4+7P873e3Hy7LsnebMZA6f QqbWhW7Dg/p2iF7oXP5EjMCEQ3AdA2WUI2ZgB53ltw+8+y3XfSS20nAiN7qRWqIqGJNd zIE4MpUyV4mhKRAic8CKdDcNJbwllyWT5mgRV11Yby2b9+aDT0Ra6Lf16w2sYAaceqtY V1K5I9FZ4jOZ76lMgCnk1YkhTH91YEho+sFe+KRslgiQt0Y2vV4xibCIZ2IGuYnfuxBZ W7JpFfxKnYaFleOd82+g28ty5l+JV9pMGCGVGAAXh7OKuiS83d9jg0kGmK+lPukC7bkv OhQg== 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=xU1X1E39UgQ6DQytLA6ceTLCCTeIezf5bvgKjuhWrDw=; b=I5uHnRUBJ9n/mFITKpAKwrsFe+zsbhqGa8WslY3LguJcxj8u0RPdjsGFqNZIkOpNWE jy+gN72iTIzIGOv+yyxKwHF2XLWQSQPgEmbWOUXgxJlVcXVMsFj7O9JFXrOsFLpQY3py JcjcIz6WZP9RdE6OHIwtrDqToc7ylRJ/GMyH+IWO73pCbIbMgpcj8Eus6UIXrzp/bE28 OLzJAFDX31XAJ33S5QUzXwHVHFRagHmL6n8S2QqDQTrarc6hgGpEVzWsSTcO6AkM2mlI ReMOhkis2Wt/KEe/Fy3Cazk1RnQuDPeTFJDe4fMtZcEtX+UFFoyME5aCnkpPQO3mxt7u VRsw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji1-20020a170907980100b0072b147e5ccbsi17236861ejc.390.2022.07.12.16.33.01; Tue, 12 Jul 2022 16:33:27 -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 S233061AbiGLW60 (ORCPT + 99 others); Tue, 12 Jul 2022 18:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbiGLW6Z (ORCPT ); Tue, 12 Jul 2022 18:58:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439E5A439F; Tue, 12 Jul 2022 15:58:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D11BB61734; Tue, 12 Jul 2022 22:58:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61B07C3411C; Tue, 12 Jul 2022 22:58:22 +0000 (UTC) Date: Tue, 12 Jul 2022 18:58:20 -0400 From: Steven Rostedt To: LKML Cc: Jakub Kicinski , Jiri Pirko , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH v2] tracing: devlink: Use static array for string in devlink_trap_report even Message-ID: <20220712185820.002d9fb5@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: "Steven Rostedt (Google)" The trace event devlink_trap_report uses the __dynamic_array() macro to determine the size of the input_dev_name field. This is because it needs to test the dev field for NULL, and will use "NULL" if it is. But it also has the size of the dynamic array as a fixed IFNAMSIZ bytes. This defeats the purpose of the dynamic array, as this will reserve that amount of bytes on the ring buffer, and to make matters worse, it will even save that size in the event as the event expects it to be dynamic (for which it is not). Since IFNAMSIZ is just 16 bytes, just make it a static array and this will remove the meta data from the event that records the size. Cc: Jakub Kicinski Cc: Leon Romanovsky Cc: Jiri Pirko Cc: "David S. Miller" Cc: Eric Dumazet Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Steven Rostedt (Google) --- Changes since v1: https://lkml.kernel.org/r/20220703111809.40cd1c3f@rorschach.local.home - The old version tried to do the same logic in the __dynamic_array() to calculate the size of the string, but actually failed to by not using the correct variable. Just use __array() instead, as IFNAMSIZ is just 16 bytes anyway. - Cc'd more maintainers by running get_maintainers.pl from the call of the tracepoint and not just the include/trace/events file. include/trace/events/devlink.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h index 2814f188d98c..24969184c534 100644 --- a/include/trace/events/devlink.h +++ b/include/trace/events/devlink.h @@ -186,7 +186,7 @@ TRACE_EVENT(devlink_trap_report, __string(driver_name, devlink_to_dev(devlink)->driver->name) __string(trap_name, metadata->trap_name) __string(trap_group_name, metadata->trap_group_name) - __dynamic_array(char, input_dev_name, IFNAMSIZ) + __array(char, input_dev_name, IFNAMSIZ) ), TP_fast_assign( @@ -197,15 +197,14 @@ TRACE_EVENT(devlink_trap_report, __assign_str(driver_name, devlink_to_dev(devlink)->driver->name); __assign_str(trap_name, metadata->trap_name); __assign_str(trap_group_name, metadata->trap_group_name); - __assign_str(input_dev_name, - (input_dev ? input_dev->name : "NULL")); + strscpy(__entry->input_dev_name, input_dev ? input_dev->name : "NULL", IFNAMSIZ); ), TP_printk("bus_name=%s dev_name=%s driver_name=%s trap_name=%s " "trap_group_name=%s input_dev_name=%s", __get_str(bus_name), __get_str(dev_name), __get_str(driver_name), __get_str(trap_name), __get_str(trap_group_name), - __get_str(input_dev_name)) + __entry->input_dev_name) ); #endif /* _TRACE_DEVLINK_H */ -- 2.35.1