Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1805926rwl; Thu, 30 Mar 2023 01:34:34 -0700 (PDT) X-Google-Smtp-Source: AKy350aThxX7633Lbhp74uZ5XSaUl9Ch5aL/kyQ4rUNMeCoIXvazK1sSrCMIxW16Exq7jrwEXL+q X-Received: by 2002:a05:6a21:6daa:b0:e1:2352:f0ea with SMTP id wl42-20020a056a216daa00b000e12352f0eamr11194969pzb.5.1680165274299; Thu, 30 Mar 2023 01:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680165274; cv=none; d=google.com; s=arc-20160816; b=QVfuosTffTT86b76KTbaBgLWp08PRuNXkMDcD3QCTTxH06OWdq55fKhEICE6farYpl lNDuc8Re9Rn0/OdWXiyQu85eWTMzcLvJH1gl3AA3zFBPeK06Bn6DWReXxujW1ONq4yvD ADS5ZN9kuuP/gKjtoZriTc+njWcuWw3VtRkxywZkdkEyHI0kI+pF28CGWYuIPHjz1xV6 krttqXLS8H7FJ0Kg2njMpxjIsUnt1JHmAd3SC1A/bNnZHjV0Tr46aXFL99dR28tlvQxR vGTuwEMWwnKE5kYI73pGLO6fRHk13/jpICP22vH3Ys86zt3NZCfq0I+NW2Kdy8UnjVm6 8xbQ== 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=4fTmAS6avoLHIq3nqQb4zrq2iALDs+rVcu5I73K0wWc=; b=KMLDtp3WG1vvaST2LhWsHBnHdpm2XedaqccTtLx2QevAnbF/l4wYFBiBzQi5YEOFv3 DRU5j53gu6BocMP7ikRSrr98Q9NyvLxpTFCHYf4ZYwUAQnwZU52ca2nSND0tDScUFOaW YCQ40iyuxJQyFT1q1Ob7yIhExt/lv2IHVFGFYHCRMUKVHOQQ6TrgYjvXnxpnUIY2yLlj ic4j44+h4crWe9sMVnXjemVMHg8L8WFFbROmwu7EH+sLHOLEulSdX3Arr0FO20w5RGwJ etsHVtUHtuOuz9fEAOSBbSA6vzGnL54WbK7kql+BIHa5mo9ctoAE/Kd0wODhieys0s4S FcVw== 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 g14-20020a63e60e000000b004fb40593898si35337373pgh.374.2023.03.30.01.34.22; Thu, 30 Mar 2023 01:34:34 -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 S229486AbjC3Icd (ORCPT + 99 others); Thu, 30 Mar 2023 04:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbjC3Ibu (ORCPT ); Thu, 30 Mar 2023 04:31:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A3F5265A1; Thu, 30 Mar 2023 01:31:33 -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 B49512F4; Thu, 30 Mar 2023 01:32:17 -0700 (PDT) Received: from [10.57.18.220] (unknown [10.57.18.220]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BFC3B3F73F; Thu, 30 Mar 2023 01:31:32 -0700 (PDT) Message-ID: Date: Thu, 30 Mar 2023 09:31:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] perf bench numa: Fix for loop in do_work Content-Language: en-US To: Andreas Herrmann , Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20230330074202.14052-1-aherrmann@suse.de> From: James Clark In-Reply-To: <20230330074202.14052-1-aherrmann@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 30/03/2023 08:42, Andreas Herrmann wrote: > j is of type int and start/end are of type long. Thus j might become > negative and cause segfault in access_data(). Fix it by using long for > j as well. > > Signed-off-by: Andreas Herrmann > --- > tools/perf/bench/numa.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Example of segfault (with 6.3.0-rc4) is: > > # ./perf bench numa mem -d -m -p 2 -t 12 -P 25425 > ... > threads initialized in 6.052135 seconds. > # > perf: bench/numa.c:1654: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed. > Aborted (core dumped) > # dmesg | grep segfault > [78812.711311] thread 1/3[43215]: segfault at 7f07936c9ec0 ip 00000000004ab6d0 sp 00007f0acb1f9cb0 error 4 > [78812.711309] thread 1/9[43221]: segfault at 7f08bda71a70 ip 00000000004ab6d0 sp 00007f0ac81f3cb0 error 4 > [78812.711316] thread 1/4[43216]: segfault at 7f07ccf76a08 ip 00000000004ab6d0 sp 00007f0aca9f8cb0 error 4 > [78812.711325] thread 1/2[43214]: segfault at 7f08be2f44b0 ip 00000000004ab6d0 sp 00007f0acb9facb0 error 4 > [78812.711328] thread 1/8[43220]: segfault at 7f06d3096b20 ip 00000000004ab6d0 sp 00007f0ac89f4cb0 error 4 > [78812.711345] thread 1/6[43218]: segfault at 7f0774b46a18 ip 00000000004ab6d0 sp 00007f0ac99f6cb0 error 4 in perf[400000+caa000] likely on CPU 6 (core 8, socket 0) > [78812.711366] thread 0/0[43224]: segfault at 7f08a936b130 ip 00000000004ab6d0 sp 00007f0acc9fccb0 error 4 in perf[400000+caa000] likely on CPU 1 (core 1, socket 0) > > diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c > index 9717c6c17433..1fbd7c947abc 100644 > --- a/tools/perf/bench/numa.c > +++ b/tools/perf/bench/numa.c > @@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val > > if (g->p.data_rand_walk) { > u32 lfsr = nr + loop + val; > - int j; > + long j; > > for (i = 0; i < words/1024; i++) { > long start, end; Reviewed-by: James Clark