Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp851152pxj; Thu, 17 Jun 2021 15:38:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSVyPfZJuNMBtwmYancdaG8mRCnCwVm7DkphbAAtwbc8Y13l9HkMGC+CpI6M5gyGVB+xVV X-Received: by 2002:a17:906:c302:: with SMTP id s2mr7603077ejz.151.1623969516966; Thu, 17 Jun 2021 15:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623969516; cv=none; d=google.com; s=arc-20160816; b=ED2ENnllIOshmR4i8BiGlboeM85kkb3v0461xqBM+tOI+Yqqsb4F+4VppepBJk8WhC yI8F05Jv1G/PZMbwgROee058QqmT2gpE4a0BAxC9cpF2A/HJyQ1hD9uyE9uvJpzzvd41 a2BEWXERvOF2yccgrLrtLWRgdGfwWBOFTbd+f3n7hWcREtXkBYj6kPQbUtw36PL9hXXL 4cY90Ah0bN6d3f5OSR8wcTMVZ87XdYmTDWrsORRb0zwhYhuPP/J6r4DHSXkPML8rVqvo Ro+5/IiZS0TUnqtkfvWf3Nh3deAGsI6lCnhOl8d3fTYAccO/xUgn/GiIErUuTPHbal6C F6OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=hdSyg9TqPjQu6XGsdPBvN/E6vO1KnQYF4mu5PsSRooc=; b=LaQygbdXe3GGM8pKePMfF31u7bFVfQntsUgWjQzOy5oN/57TnJYS3aSyKFm1n2hQ/4 6xztGU1yZE/Z7nuHIvqHZH+k/4vS6iOTrBFBOdtTryeMiZCFHZmENia/3Q0e92DvT4pc JH5WxMSF/lof1CV/khk5HE8TTmHkrFXYmpALgfrPwxE4TZykDTxjnzt/6j1xEUWN0OeK aM4zsiVR31uQ+7aTX1sasorhpGEJdYcucEu+EiMLScnDG298fwjoNrifQailSRqiHrZn LNzhc5D5CciH4ld0V9yTHECUvziEUaygHZM/h2uPc6/UjU/2XO5pIGh7qPX0GXYo5vzQ oIgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si6943913eds.477.2021.06.17.15.38.13; Thu, 17 Jun 2021 15:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232547AbhFQRuW (ORCPT + 99 others); Thu, 17 Jun 2021 13:50:22 -0400 Received: from foss.arm.com ([217.140.110.172]:57196 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbhFQRuV (ORCPT ); Thu, 17 Jun 2021 13:50:21 -0400 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 771F513D5; Thu, 17 Jun 2021 10:48:13 -0700 (PDT) Received: from [10.57.9.136] (unknown [10.57.9.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A1CF13F694; Thu, 17 Jun 2021 10:48:12 -0700 (PDT) Subject: Re: [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number To: Tuan Phan Cc: Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1623946129-3290-1-git-send-email-tuanphan@os.amperecomputing.com> From: Robin Murphy Message-ID: Date: Thu, 17 Jun 2021 18:48:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1623946129-3290-1-git-send-email-tuanphan@os.amperecomputing.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-17 17:08, Tuan Phan wrote: > When multiple dtcs share the same IRQ number, the irq_friend which > used to refer to dtc object gets calculated incorrect which leads > to invalid pointer. Oops, indeed this is supposed to be a forward offset *from* the previous match *to* the current dtc. It's almost as if I never managed to test it... :) Reviewed-by: Robin Murphy > Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver") > > Signed-off-by: Tuan Phan > --- > drivers/perf/arm-cmn.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c > index 56a5c35..49016f2 100644 > --- a/drivers/perf/arm-cmn.c > +++ b/drivers/perf/arm-cmn.c > @@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn) > irq = cmn->dtc[i].irq; > for (j = i; j--; ) { > if (cmn->dtc[j].irq == irq) { > - cmn->dtc[j].irq_friend = j - i; > + cmn->dtc[j].irq_friend = i - j; > goto next; > } > } >