From patchwork Tue Jul 11 14:15:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 118572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp525915vqm; Tue, 11 Jul 2023 07:36:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDRJQGHvLhoN8S7akvFeJ6pq/CV59+y4rvoCnzOuvu1iERuz5/tFdABSM+Pf3EE0SITEci X-Received: by 2002:aa7:d50d:0:b0:51d:fa7c:c330 with SMTP id y13-20020aa7d50d000000b0051dfa7cc330mr16307816edq.26.1689086171902; Tue, 11 Jul 2023 07:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689086171; cv=none; d=google.com; s=arc-20160816; b=O7Q5yJZ0YqinhU3TBikuOp2o5QvdE+3gfkG7Vfvi6k2EWe7IVWKrpU21YFlcHaVpW5 dJ/cFSZR4vRMhenzdokeMW2JCvC3K+2FUYY50xfSIccCl7r1NcJS16MHt+TK60eow5bf MByM/X1x+m4aS1MqVE7sXwmWEyjRRmYaKZQ3cgXFVHr6DjRDc2gVQ+xkgjb3liVVItXT fA6+ylONgaD7yWcbxu2Kq4gH8chVWTxuwx5Kay/G3ZmcPChaTf0qVmJm++4kRcCNy25S 8mfcAjWzzJw9tD6oMzJvZeFF6L7NRJPGHAOWDvjdmfvITFbdmOkP8+o8k0EUvVXCev/Y hXtw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d+NOB/WONAqzzZgmWSMzf9e8LMOvk34KXJAn/twOYSk=; fh=hf24JvveL55vCfzfv0agRHDWsuhzZqIeZ7dfs5kcUjQ=; b=p3AM0BdMcCNzNhkT3ydn4ke8IoGPVbaBQm26yrQHAkXz+Qdwj0y/RUzjISFRILcYNR 323ZksiX7/3nyN9cS66Dhi8IQ4f7Z5JPxPi5nKOMbI7MmFsMEsp2I/F7t9yrh3LpHDZc zULzj363nC1XQhwMjhvM2/ML7gFuxcNhd/oFdgCgQyW8lDj4mFIYfGtGcyWn+OlhbusU q+6K4WgbbnOpkyMxWvEW9nuH+yMuyNhBQaIWvKENDnCRZTeVQryDmWncBBCABesmjlVU dVmouMZbcuqM2gV1xnH8dCwfR69iVXkkxlbfrE2GKyWhAc/d8NdBtj5LW0PzSR0KBTEb eG7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aReD0A+1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020aa7c1cc000000b0051e26731172si2055205edp.672.2023.07.11.07.35.47; Tue, 11 Jul 2023 07:36:11 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aReD0A+1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232906AbjGKOP7 (ORCPT + 99 others); Tue, 11 Jul 2023 10:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbjGKOPy (ORCPT ); Tue, 11 Jul 2023 10:15:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6C8170A; Tue, 11 Jul 2023 07:15:53 -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 D15646150C; Tue, 11 Jul 2023 14:15:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEEF1C433C8; Tue, 11 Jul 2023 14:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689084952; bh=5Y9sWGJd4HJzLogg+iWU8edbrK9/5rH7d1aurm3YzgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aReD0A+1tRpSeAhG5xZHxoEfgPqj/cIAjHv5Z4zOwhd3S7Z4wLSHzDiwKz3dWmVPB olT6rBr8eKo6yrOVIN/QlfyLwLhToLP9rNvm0gIdSpX9aPA+9Yv/6SL/7J4uqSsMjC zHrhLLgcGapkXdRl+Ga4UB03d368RaOzFaoU+ILQhCICSDUW3gzAxhTD7Lfo+Kuvxt jOoJdydJtXRmH/EoxUaPd5caAnHcUz2ElaFcA6ig8tiPnq09t6IiIXQSMuljQ9RAXQ rXpVzluE6t3+fiwKXb4yON3bOY56bvM08Pj3bzk8blEgezzi7N3HgIcOYDgMs6nFk8 LWHO/woKPxf4A== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v5 3/5] tracing/probes: Fix to update dynamic data counter if fetcharg uses it Date: Tue, 11 Jul 2023 23:15:48 +0900 Message-Id: <168908494781.123124.8160245359962103684.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <168908491977.123124.16583481716284477889.stgit@devnote2> References: <168908491977.123124.16583481716284477889.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771135221847571799 X-GMAIL-MSGID: 1771135221847571799 From: Masami Hiramatsu (Google) Fix to update dynamic data counter ('dyndata') and max length ('maxlen') only if the fetcharg uses the dynamic data. Also get out arg->dynamic from unlikely(). This makes dynamic data address wrong if process_fetch_insn() returns error on !arg->dynamic case. Suggested-by: Steven Rostedt Link: https://lore.kernel.org/all/20230710233400.5aaf024e@gandalf.local.home/ Fixes: 9178412ddf5a ("tracing: probeevent: Return consumed bytes of dynamic area") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- kernel/trace/trace_probe_tmpl.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index ed9d57c6b041..185da001f4c3 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -267,11 +267,13 @@ 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 { - dyndata += ret; - maxlen -= ret; + if (arg->dynamic) { + if (unlikely(ret < 0)) { + *dl = make_data_loc(0, dyndata - base); + } else { + dyndata += ret; + maxlen -= ret; + } } } }