From patchwork Tue Jul 11 14:15:38 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: 118562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp517471vqm; Tue, 11 Jul 2023 07:22:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHussN7mMiAtPCf2q7SKsLxqGqr9gLBrn0KjGaf7e7BqEZao3CtkbB6SsMzcAWkcuD2KxzF X-Received: by 2002:a17:906:19:b0:982:82aa:86b1 with SMTP id 25-20020a170906001900b0098282aa86b1mr15321424eja.43.1689085365853; Tue, 11 Jul 2023 07:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689085365; cv=none; d=google.com; s=arc-20160816; b=j9C1rS+w8i8KaH/NWKpeAgjQE07Eu9ax56kbqwm+jtBG3HHzn5EpNOGlSUO0FOfVZN vehnTOB9r56XPF8qMjeTfx1p7saXWzs25R1+yZuGbofP0iIUC3I5SXrLPZYvwlpinoJR aG0+E3pJscDbxBObVjSvbwS2F5FtRF4Sqmzlx210zlWMr9J+j3Y97jrfGVyAMHQgCzzP +hwIdOm8pVBqbxBIONsjuO603vzv7DVCeM97q/NcG/3aH/CO3+5NPijfgvKEtzfjqysv SkVEHwVTZGavCQUsHIAgu9zHxUvB6iHW+yzAfT6RE4W4+e6L9Mtz7t7vGYXD4UDb+WS2 T2Pw== 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=r89tSstUd87KxVgKJyc9fOJO7qDKtqqI7NTmITIB3KQ=; fh=hf24JvveL55vCfzfv0agRHDWsuhzZqIeZ7dfs5kcUjQ=; b=PYrJDCUE6kg76U6GDJefss8S/pNg0IXtZj+4ELSBU/CheonTx145R5iEumlFc1X/l4 5ZOjrJMvna17iiAa86TZ0eilQQllw1/IU5gvrPCFhdrlrpa3UlU5suOovUGALugocQAn N900Ap/kyGr296dxwW6ZoGLPh8iKWKmMUHKhFbQfq6j9U7sX+/l9LC9TyStqA2Ioc/cA wfZBymoQiMvl5BBxEo3ulFwiGSEfUw4+1RFoHb/r13iglvhdmCoPxhtLIC8uRI+tPd/W sMjcN+mtDLSAc/KrgmuCdb8P9A5jSfbuPTimOzUvb5iKHxNDs9/wKqbMOaVDr9Asbv3c K4bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tsqVZDBr; 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 op10-20020a170906bcea00b00991f9e2a81asi2291093ejb.238.2023.07.11.07.22.21; Tue, 11 Jul 2023 07:22:45 -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=tsqVZDBr; 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 S233462AbjGKOPq (ORCPT + 99 others); Tue, 11 Jul 2023 10:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbjGKOPo (ORCPT ); Tue, 11 Jul 2023 10:15:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79870B0; Tue, 11 Jul 2023 07:15:43 -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 16C1D6150D; Tue, 11 Jul 2023 14:15:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0848FC433C8; Tue, 11 Jul 2023 14:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689084942; bh=B/xbZAcfESero9MbnK8hn07jc1YnxzqHt+73/OKFhoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsqVZDBrt4sxiMKWtpCFTvByTQZFO7mAdGegliLhzJXs15V7YqWsqgnHerRcec5U+ Q/aaehktA8TSQGy3P2IRj2d9B6EYVTJ+OCKfI/Tfo17m6Rqe1hWpQQW6gLX9r7YOzV VeakEbJVbz9A5ixmsRtkWbHgzaYCL5u/Y7fFK/4vK2ugWUfhC94NjpyxXdz0df++TV 6Zqq6oeZmITh9QUwuYUDk8+gH+gny3tsYjFJqtLbbAFf99Us4d5y94mShmPB1DbFXl ggzQkydSW+OAFgriURtQRzGL9eaRhw2gcBBwwp+58HckLCUKp+XJm+/88Uiegq+3y2 vRhEWB1Io84fA== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v5 2/5] tracing/probes: Fix not to count error code to total length Date: Tue, 11 Jul 2023 23:15:38 +0900 Message-Id: <168908493827.123124.2175257289106364229.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: 1771134376678683387 X-GMAIL-MSGID: 1771134376678683387 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) --- 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;