Message ID | 20230131095237.63e3ca8d@gandalf.local.home |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2795909wrn; Tue, 31 Jan 2023 06:59:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXte/NZ0liR291ceKFOtrKclHSRL+MZNxCoibD84L4DEdy+h6cft/Dd9VuhOtLhTK/Tu7kcs X-Received: by 2002:a17:907:6d87:b0:84d:3fa7:12e5 with SMTP id sb7-20020a1709076d8700b0084d3fa712e5mr76844243ejc.32.1675177190850; Tue, 31 Jan 2023 06:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675177190; cv=none; d=google.com; s=arc-20160816; b=tMFldGxApdQ4JkMvf5lyboeS9QlFFTC+0GoB/UEIRauKeHvxoM10JITu3bcgHTLD4m nUhCwdcfZhcIFzo4SW6A02As0dy5j41yJ0CgNvnAgyzSlatfnPliZHpgahD8e5IN46B0 TL0HNZHM3mMIaV0iGnqV19XwNDcdkz/XjYVH7D40gR6rS4IBOAD37VGIl16Jv2Ugjbw8 Srr5giA+Xcr6abeipqiLzK3Hj5ccMADfYXWMYsVxA5y/dQU65z2/aD/jMCPlxnrKZ7bq 0hk7gcJkOQh7iaCk1IxWWF4PCMV3yK3OgkaTVaRvFfEM7KL4hrHWN1q2cH+Gn1jeo0fK 676g== 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=zdADqUujmAQyyZ/zX1sc8BL9A2NB/UtcpC1D+ct9GKc=; b=dUu/o7LSSEEeR3EU3/dJmca/Rfu+NHqsaGS33R4oOSL/qSFh2A8PEhlRzsmxIj4Bak uoRSwgsdXGLl+/HuEPmD5zAnRMuYM7oC49GTBNr0KViUIgB8gOqyYdcVqObk/12TMdXe DWex3f0ZqfLgXKA4US26pRRQ3KiSeg5zn/FqM3mw/nXzsMRZmfN34Sy3ZmMCD8/Eog8w 5eKV8FcBPFKhkYVE3LEbb1BdySnd7wmWg1L6jXpmFFK3u2n7sND9Lj1ZJXVWMVfiVzzc JTw9in8YS5/LmNXTZ2El9vTaTZ8qRgeiScefMbNBpVfxEMJfi4VM1VN5USKYTufqIegi L2GA== 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 21-20020a170906029500b00882ba4a133esi13275640ejf.404.2023.01.31.06.59.13; Tue, 31 Jan 2023 06:59:50 -0800 (PST) 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 S232143AbjAaOwm (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Tue, 31 Jan 2023 09:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231723AbjAaOwl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Jan 2023 09:52:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEF0215CAE; Tue, 31 Jan 2023 06:52:40 -0800 (PST) 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 59E3D61546; Tue, 31 Jan 2023 14:52:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C850C433EF; Tue, 31 Jan 2023 14:52:39 +0000 (UTC) Date: Tue, 31 Jan 2023 09:52:37 -0500 From: Steven Rostedt <rostedt@goodmis.org> To: LKML <linux-kernel@vger.kernel.org>, Linux Trace Kernel <linux-trace-kernel@vger.kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org>, Tom Zanussi <zanussi@kernel.org>, kernel test robot <lkp@intel.com> Subject: [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement Message-ID: <20230131095237.63e3ca8d@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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756550597752857857?= X-GMAIL-MSGID: =?utf-8?q?1756550597752857857?= |
Series |
tracing: Fix trace_event_raw_event_synth() if else statement
|
|
Commit Message
Steven Rostedt
Jan. 31, 2023, 2:52 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The test to check if the field is a stack is to be done if it is not a string. But the code had: } if (event->fields[i]->is_stack) { and not } else if (event->fields[i]->is_stack) { which would cause it to always be tested. Worse yet, this also included an "else" statement that was only to be called if the field was not a string and a stack, but this code allows it to be called if it was a string (and not a stack). Also fixed some whitespace issues. Link: https://lore.kernel.org/all/202301302110.mEtNwkBD-lkp@intel.com/ Fixes: 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/trace/trace_events_synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Tue, 31 Jan 2023 09:52:37 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > From: "Steven Rostedt (Google)" <rostedt@goodmis.org> > > The test to check if the field is a stack is to be done if it is not a > string. But the code had: > > } if (event->fields[i]->is_stack) { > > and not > > } else if (event->fields[i]->is_stack) { > > which would cause it to always be tested. Worse yet, this also included an > "else" statement that was only to be called if the field was not a string > and a stack, but this code allows it to be called if it was a string (and > not a stack). > > Also fixed some whitespace issues. > Looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Hmm, I need to add more tests for syntax events... Thanks! > Link: https://lore.kernel.org/all/202301302110.mEtNwkBD-lkp@intel.com/ > > Fixes: 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces") > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> > --- > kernel/trace/trace_events_synth.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c > index adb630633f31..306c89e0ce55 100644 > --- a/kernel/trace/trace_events_synth.c > +++ b/kernel/trace/trace_events_synth.c > @@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data, > event->fields[i]->is_dynamic, > data_size, &n_u64); > data_size += len; /* only dynamic string increments */ > - } if (event->fields[i]->is_stack) { > - long *stack = (long *)(long)var_ref_vals[val_idx]; > + } else if (event->fields[i]->is_stack) { > + long *stack = (long *)(long)var_ref_vals[val_idx]; > > len = trace_stack(entry, event, stack, > data_size, &n_u64); > -- > 2.39.0 >
On Wed, 1 Feb 2023 00:36:33 +0900 Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > Looks good to me. > > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Hmm, I need to add more tests for syntax events... I was thinking the same thing, as they should have caught this ;-) -- Steve
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index adb630633f31..306c89e0ce55 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data, event->fields[i]->is_dynamic, data_size, &n_u64); data_size += len; /* only dynamic string increments */ - } if (event->fields[i]->is_stack) { - long *stack = (long *)(long)var_ref_vals[val_idx]; + } else if (event->fields[i]->is_stack) { + long *stack = (long *)(long)var_ref_vals[val_idx]; len = trace_stack(entry, event, stack, data_size, &n_u64);