Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3548971rwo; Fri, 4 Aug 2023 06:39:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF71vGVn7iCbw6YKfz60QHVpVe74wFI03CNUrF+d7i3rpcj6jPHdWQHoHmDWKgBpYGudN9P X-Received: by 2002:a05:6a00:23c5:b0:687:83c8:1425 with SMTP id g5-20020a056a0023c500b0068783c81425mr2150433pfc.0.1691156360361; Fri, 04 Aug 2023 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691156360; cv=none; d=google.com; s=arc-20160816; b=U3XyJn/FEMEDVPE7FXRYYQH2IKW4Y5DbYSsW4LpUM+UHPy35jmNjcTY4ihQ2D18swv cFPBJJlq9qnA72kuMRy8CMGG5s2bFjeMXx+TxtNQuv7soTJOqzWMfbdsvjNptZw8YBKU bUF5IEr2Ek/WstFYwI+sNsmdSXul0Oqe8qtAMp/h1sow3AaABHx63ElJHoedNXnqCZ4S FevHRtUyNrJWFNwAKtLmXEiq8IewurtEZuFEUPeLVllobE+KyOt13bd15rGC29ZSxk1k OnDa4k5dhGJLesamDNYDstPoKKb3pJ95RSwa3snNT2T5Izgp9Syu8BWVQgulDFH+vEXr ZAMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=XzrvQn67GedY6nL0EqJc17mSLNLExeS/XS8jRiWdjCs=; fh=nO4hATT69qKXGlNeL1vQUDeEYYX2JJk665FSca22UjI=; b=oYUE08gu00izJL0SIu8l3oIdAME5RMa7skNxcp06vznauONr6f8W30m8V9Ue9PWgX8 V6ysOi+hHarSOx1j2Tb0uYBhw9VCXmfqWkLx7k6+GJjDkFVQYF+jVwxdN2JbdwYjjlxG QUbexQBT+TzpUZUrhvw1B510UMUUW1D7OfkLqKvdbAlOfVyqown61JaGrFdJpIab2Y4D EYIq8S1G8EnrmGoB+19dQTbR1IO2Rv9i36fbPRUkNrx6i/ikIpJxBJPTNoRwa3ZBDmpU JlEM5Z93hil8ZgpVzCrgR65hTWW+kB++itrZq8tW99OB+XCo3hRMRU7RGhDdPaP6IA8p UV5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq5-20020a056a00330500b006872a89502csi1722716pfb.186.2023.08.04.06.39.07; Fri, 04 Aug 2023 06:39:20 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjHDN0t (ORCPT + 99 others); Fri, 4 Aug 2023 09:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjHDN0n (ORCPT ); Fri, 4 Aug 2023 09:26:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80A3E4C1E for ; Fri, 4 Aug 2023 06:26:19 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 223851007; Fri, 4 Aug 2023 06:17:15 -0700 (PDT) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 668A33F5A1; Fri, 4 Aug 2023 06:16:31 -0700 (PDT) Message-ID: Date: Fri, 4 Aug 2023 14:16:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 1/1] coresight: tmc: Explicit type conversions to prevent integer overflow Content-Language: en-US To: Ruidong Tian , linux-kernel@vger.kernel.org Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org, james.clark@arm.com References: <20230714084349.31567-1-tianruidong@linux.alibaba.com> <20230804081514.120171-1-tianruidong@linux.alibaba.com> <20230804081514.120171-2-tianruidong@linux.alibaba.com> From: Suzuki K Poulose In-Reply-To: <20230804081514.120171-2-tianruidong@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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 On 04/08/2023 09:15, Ruidong Tian wrote: > Perf cs_etm session executed unexpectedly when AUX buffer > 1G. > > perf record -C 0 -m ,2G -e cs_etm// -- > [ perf record: Captured and wrote 2.615 MB perf.data ] > > Perf only collect about 2M perf data rather than 2G. This is becasuse > the operation, "nr_pages << PAGE_SHIFT", in coresight tmc driver, will > overflow when nr_pages >= 0x80000(correspond to 1G AUX buffer). The > overflow cause buffer allocation to fail, and TMC driver will alloc > minimal buffer size(1M). You can just get about 2M perf data(1M AUX > buffer + perf data header) at least. > > Explicit convert nr_pages to 64 bit to avoid overflow. > > Fixes: 22f429f19c41 ("coresight: etm-perf: Add support for ETR backend") > Signed-off-by: Ruidong Tian > Reviewed-by: James Clark > --- > drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- > drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++-- > drivers/hwtracing/coresight/coresight-tmc.h | 2 +- > 3 files changed, 5 insertions(+), 4 deletions(-) Added additional Fixes tags as required and pushed it here : https://git.kernel.org/coresight/c/fd380097cdb3 Thanks! Suzuki