From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA10CEB64DC for ; Tue, 11 Jul 2023 03:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbjGKDeH (ORCPT ); Mon, 10 Jul 2023 23:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjGKDeG (ORCPT ); Mon, 10 Jul 2023 23:34:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79D72E8; Mon, 10 Jul 2023 20:34:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 18037612D5; Tue, 11 Jul 2023 03:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1523C433C7; Tue, 11 Jul 2023 03:34:03 +0000 (UTC) Date: Mon, 10 Jul 2023 23:34:00 -0400 From: Steven Rostedt To: "Masami Hiramatsu (Google)" Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML Subject: Re: [PATCH v4 4/4] tracing/probes: Fix to record 0-length data_loc in fetch_store_string*() if fails Message-ID: <20230710233400.5aaf024e@gandalf.local.home> In-Reply-To: <168904151104.2908673.8401909922292791503.stgit@mhiramat.roam.corp.google.com> References: <168904147563.2908673.18054267804278861545.stgit@mhiramat.roam.corp.google.com> <168904151104.2908673.8401909922292791503.stgit@mhiramat.roam.corp.google.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org On Tue, 11 Jul 2023 11:11:51 +0900 "Masami Hiramatsu (Google)" wrote: > --- a/kernel/trace/trace_probe_tmpl.h > +++ b/kernel/trace/trace_probe_tmpl.h > @@ -267,9 +267,7 @@ store_trace_args(void *data, struct trace_probe *tp, void *rec, > if (unlikely(arg->dynamic)) > *dl = make_data_loc(maxlen, dyndata - base); > ret = process_fetch_insn(arg->code, rec, dl, base); > - if (unlikely(ret < 0 && arg->dynamic)) { > - *dl = make_data_loc(0, dyndata - base); > - } else { > + if (unlikely(ret > 0 && arg->dynamic)) { To match the current code, that should be: if (likely(ret >= 0 || !arg->dynamic)) { But I'm guessing that the original code was buggy, as the else block should only have been processed if arg->dynamic was set? That is, it should have been: if (arg->dynamic) { if (unlikely(ret < 0)) { *dl = make_data_loc(0, dyndata - base); } else { dyndata += ret; maxlen -= ret; } } I guess you only want to update if arg->dynamic is true (even though that wasn't the case before :-/) But in any case, I think you want likely() and not unlikely(). if (arg->dynamic && likely(ret > 0)) { That is, if we only want to updated this if the arg is dynamic. And I don't think that the arg->dynamic() should have likely/unlikely around it, as that's determined by user space, and the kernel should not be adding assumptions about what user space wants. -- Steve > dyndata += ret; > maxlen -= ret; > }