From patchwork Fri Jul 7 13:40:54 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: 13304896 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 563D9EB64D9 for ; Fri, 7 Jul 2023 13:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbjGGNlC (ORCPT ); Fri, 7 Jul 2023 09:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjGGNlB (ORCPT ); Fri, 7 Jul 2023 09:41:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFE02119; Fri, 7 Jul 2023 06:40:58 -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 5AEAF619AB; Fri, 7 Jul 2023 13:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DBD8C433C8; Fri, 7 Jul 2023 13:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688737257; bh=zwpa7syMeSYhTZBa9ItWWjpkC7dz4g0aJQWZT5Tc5g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZWm0UKoKPO+iKHdiVOKfGSMpBCnguPRrOUOZ2mtN0mmJ/n1svC2gSEC5BQf4G+e6N C2qWZM1vqdhu2maaFqrUzTAljaLKQfzJH+hVt5qMUSQzgSyX4mau8swuxz2bLd1lQN w8L5SHydC14vXPZ02X1R50llhAR/7Lo1xtAtA52K/P+nrcaMpEY6PIeT2qqwZ9WQPX JZ1w3w0ttV0lFCwoTdaVFWPBC2NrAvmuoWr9NLtunQPqmOT7fKDDh0qRtizsCFEX+z XMumuQrqWWLXNm+Fl/PP5VmEdjmUQFlWr8M7SoMhxuOmpBd9wF1uRoyyvYC7wZBBzH IEapctPwaewQA== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v2 1/4] tracing/probes: Fix to avoid double count of the string length on the array Date: Fri, 7 Jul 2023 22:40:54 +0900 Message-ID: <168873725438.2687993.9530647538314564885.stgit@mhiramat.roam.corp.google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <168873724526.2687993.15242662075324919195.stgit@mhiramat.roam.corp.google.com> References: <168873724526.2687993.15242662075324919195.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) If an array is specified with the ustring or symstr, the length of the strings are accumlated on both of 'ret' and 'total', which means the length is double counted. Just set the length to the 'ret' value for avoiding double counting. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/ Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space string") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- Changes in v2: - Fix patch description. --- kernel/trace/trace_probe_tmpl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 00707630788d..4735c5cb76fa 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -156,11 +156,11 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, code++; goto array; case FETCH_OP_ST_USTRING: - ret += fetch_store_strlen_user(val + code->offset); + ret = fetch_store_strlen_user(val + code->offset); code++; goto array; case FETCH_OP_ST_SYMSTR: - ret += fetch_store_symstrlen(val + code->offset); + ret = fetch_store_symstrlen(val + code->offset); code++; goto array; default: