From patchwork Fri Sep 8 20:39:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 137803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp816918vqo; Fri, 8 Sep 2023 15:08:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzC6PhFkGhOldJUtPWz92pJrFqEVMnfLtqcbTGl5x0jXc1vCG9OucNbqAqzmYbZ1EmK5oj X-Received: by 2002:a17:90a:fe89:b0:271:7a79:ecbb with SMTP id co9-20020a17090afe8900b002717a79ecbbmr4164320pjb.28.1694210930248; Fri, 08 Sep 2023 15:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694210930; cv=none; d=google.com; s=arc-20160816; b=I0qwaN70jNpObE79zdmkJENeppB/44bUyvFVxVg/Sg4D8ENaBh/hUBj19misT60+vc f6Pv02ztNjtFybH5ZQb6AwcI+1BijjzHYQJf0tByGL4uhckrYUGQYRgwxNtP1dqgX4Ww 0QuSy+wSH4Eje990Swo9ON2KXstRBdJD1VQJrBfDS1LVzk7Bzh7Boimh3s6WE6fLbyrf JIL4ps3JDb1CVnVGIOeLfqRJaCVqvbqY1h4YYQ/rr/M+EyEiHTnGyou9cPItY5llt1AT TYX57f6MM8VuEIeAWB8Rxucdze4O5lAlyOuOCophFw+w5dMwT/YU28CiCx97jhTzs2pt 2ybQ== 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=SYr9yo3vODrsvrC+4AEAYtUdTVi5c174oy5VGS9FZQM=; fh=JA3MgvobDRDMlQ9Wt7NdmBgkIvqMdiDyazkNbT2Mxpc=; b=ZfMslii5k56XChQ3FWHxWFQr1M1MYwcfkicKNXsqoc1DpB20N3oag9JYJMzbWoBJcW 8QvKKyjcP+kMBH+7uYZuohoBRadyTJA2cD9nA5CWjf2t7EK1B5DCFk1pv92feKL4MIwC 7oe1Ely4dlnYFpv2AXeMrLUA/+TdzUgkdmMHzNdGl5N7KA+u4X032mJkfwz7Nx9oKxB6 yPQ6vXb0nxDmFJSey1XQLWGwatW7yxaaDanK0poJXb+rQ08UXzZ0Pyjp30cMQce8oapD 9Xhut1+mp7Gt/hmeonbXjGMDrXTJB6FSqJOiYESlg4PYHNMcbZMuVB1VSKVbEk1ck3Cu LGaQ== 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 cp16-20020a17090afb9000b0026f53377e78si3985389pjb.99.2023.09.08.15.08.43; Fri, 08 Sep 2023 15:08:50 -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 S243773AbjIHUjk (ORCPT + 39 others); Fri, 8 Sep 2023 16:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242000AbjIHUjk (ORCPT ); Fri, 8 Sep 2023 16:39:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF894B2; Fri, 8 Sep 2023 13:39:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE3C4C433C8; Fri, 8 Sep 2023 20:39:14 +0000 (UTC) Date: Fri, 8 Sep 2023 16:39:29 -0400 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mark Rutland , Sven Schnelle Subject: [RESEND][PATCH] tracing/synthetic: Fix order of struct trace_dynamic_info Message-ID: <20230908163929.2c25f3dc@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776508920431398922 X-GMAIL-MSGID: 1776508920431398922 From: "Steven Rostedt (Google)" To make handling BIG and LITTLE endian better the offset/len of dynamic fields of the synthetic events was changed into a structure of: struct trace_dynamic_info { #ifdef CONFIG_CPU_BIG_ENDIAN u16 offset; u16 len; #else u16 len; u16 offset; #endif }; to replace the manual changes of: data_offset = offset & 0xffff; data_offest = len << 16; But if you look closely, the above is: << 16 | offset Which in little endian would be in memory: offset_lo offset_hi len_lo len_hi and in big endian: len_hi len_lo offset_hi offset_lo Which if broken into a structure would be: struct trace_dynamic_info { #ifdef CONFIG_CPU_BIG_ENDIAN u16 len; u16 offset; #else u16 offset; u16 len; #endif }; Which is the opposite of what was defined. Fix this and just to be safe also add "__packed". Link: https://lore.kernel.org/all/20230908154417.5172e343@gandalf.local.home/ Cc: stable@vger.kernel.org Fixes: ddeea494a16f3 ("tracing/synthetic: Use union instead of casts") Signed-off-by: Steven Rostedt (Google) --- [ Resending to the correct mailing list this time :-p ] include/linux/trace_events.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 12f875e9e69a..21ae37e49319 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -62,13 +62,13 @@ void trace_event_printf(struct trace_iterator *iter, const char *fmt, ...); /* Used to find the offset and length of dynamic fields in trace events */ struct trace_dynamic_info { #ifdef CONFIG_CPU_BIG_ENDIAN - u16 offset; u16 len; + u16 offset; #else - u16 len; u16 offset; + u16 len; #endif -}; +} __packed; /* * The trace entry - the most basic unit of tracing. This is what