From patchwork Tue Jul 11 02:11:33 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: 13307969 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 00B8AEB64DA for ; Tue, 11 Jul 2023 02:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbjGKCLm (ORCPT ); Mon, 10 Jul 2023 22:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231433AbjGKCLl (ORCPT ); Mon, 10 Jul 2023 22:11:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A64AF1B8; Mon, 10 Jul 2023 19:11:37 -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 2598D61143; Tue, 11 Jul 2023 02:11:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E3FBC433C7; Tue, 11 Jul 2023 02:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689041496; bh=AdroxX5P9OziwCjJV/WVhJbrj4bvgg6m7fGwBk22czA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LS4AZJplDnDayCGJge+ulo91nFVzhLWCK+OVYOp6KEvdYeMgIPAIGZj7Rr2oXHf7e LrM3oqwHxdnma4Owrc4QvoL8qzsdF2j7kuBGX3un+bDNXRuvOzw5oLVu/D7SemlfN3 1IOFCmtcWnwLo1WCpJNHG7kafoAqGN7Tez659foxUn1DCcwo6KAX8GGV0kzGNPnjt0 7tBlsytl1ddqvtWU1/uYCU+L2s9ezpHETaz0Ddt/UuUbwVLjPWjO8sm9tztmh+uJ0Z fOX+d5a2fzQeGqMxU3OdfL53avUIMVkK0o6irrYsSVXimweeUlz0DFvAims+f/zs6C UsV8mZDNa+Xrw== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v4 2/4] tracing/probes: Fix not to count error code to total length Date: Tue, 11 Jul 2023 11:11:33 +0900 Message-ID: <168904149337.2908673.1200969484356641870.stgit@mhiramat.roam.corp.google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <168904147563.2908673.18054267804278861545.stgit@mhiramat.roam.corp.google.com> References: <168904147563.2908673.18054267804278861545.stgit@mhiramat.roam.corp.google.com> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org From: Masami Hiramatsu (Google) Fix not to count the error code (which is minus value) to the total used length of array, because it can mess up the return code of process_fetch_insn_bottom(). Also clear the 'ret' value because it will be used for calculating next data_loc entry. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/ Fixes: 9b960a38835f ("tracing: probeevent: Unify fetch_insn processing common part") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- Changes in v2: - Check and clear ret only for the array argument. --- kernel/trace/trace_probe_tmpl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 4735c5cb76fa..ed9d57c6b041 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -204,6 +204,8 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, array: /* the last stage: Loop on array */ if (code->op == FETCH_OP_LP_ARRAY) { + if (ret < 0) + ret = 0; total += ret; if (++i < code->param) { code = s3;