Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp616665pxb; Tue, 5 Apr 2022 16:04:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaiNLCtr6UtnHgPxHcpR6H4IbUgintvylfyohiEGd6UmVuZL98+ne7guufF0YqDdX1SGXz X-Received: by 2002:a17:902:ba8e:b0:151:ed65:fda4 with SMTP id k14-20020a170902ba8e00b00151ed65fda4mr5777248pls.127.1649199882553; Tue, 05 Apr 2022 16:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649199882; cv=none; d=google.com; s=arc-20160816; b=KFS55nhmJT06LWoUTsv0oicVqDJ2E74E9nd+scsl8Ro5p2VxuoApXHWSZHsyhDxNsx J07J6Pqw1f2DtX4Ad04cBv66ubk5I+c4iWFogOJO5G8ELjfB1VOUzh7TmfYdQ6oOMde3 Vo7byxH8/FloTcBcjSyyM9Py3X9jhUtBiABmQUvv4S5hgEIAIQIlgQzCl5Xzee6RCaJC /3diZyUtLEzg3U3iAsH7Yewh/LYtugRggitG0zzBm8pG3XqdWSGOp4CH/1wdvFiCLEDL ngLkNMi03ePBL2YBkPQMz9QUaEo2zm4raMkhHTA+FFceqeruT6m2ePWGX6r/hPdOzpof 1iXQ== 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=3SNXRZdVDN9ZnY7FDkzmD7wxkTGcWaik/ejw3JSVYDU=; b=d7m4k0P+7TszAPJY8f0PEIHIRxlBdBB+PL00n4rJ9BIwcmOQGeVCSFMKL5ceGmfYuE MIoFhBjSMgwCPLa5SIMpBjLWrS3xvzxu1tEr92IjkJ5duJNAm6mMKE3wRfgkzyEE7bDI KWsGf2yeUCHEzvXPU7UY4ysNGgUj5Q/fJllxhjztEQ+iide6ULhqROZHj43YQkYwPBTo JHYyU+Yb4fSpOQUTxx+qHACNBxaRIT7WxO7aBGn4HpMPopN3Fhzm/WjsIhputFPuiOr8 soinqk6bh5zZVxX3yyOF8RjlKoOu5iiZMBYvmySWlbfhwUl54lQFpQDdWHw+0Z03N9nf ZI6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgxkg8i1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lj14-20020a17090b344e00b001c6d68d4536si3357648pjb.41.2022.04.05.16.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:04:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgxkg8i1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0370B114377; Tue, 5 Apr 2022 15:47:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235531AbiDEPFU (ORCPT + 99 others); Tue, 5 Apr 2022 11:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345372AbiDEJnZ (ORCPT ); Tue, 5 Apr 2022 05:43:25 -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 8933CC12D9; Tue, 5 Apr 2022 02:28:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 75AB46165C; Tue, 5 Apr 2022 09:28:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80BCEC385A0; Tue, 5 Apr 2022 09:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150924; bh=VAF5i6aKP1e/tf2Wm8Jq42UU+785ciOTpaHVQGl6Dug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgxkg8i1e4zmytmPpN71HXLsNRZ6OG56/yU4FCW1je5cByuyqdRtA3loDuGxczylW lNBVcXPj20ltFAIqfByHDLki7hgbJvGdL4D6YAE+KiKSq5xtBhZU0U6TGAK46818Yl 30hFhGRjA83a1DPbY+YZL6GFJtS9XILSsszvcLTA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Alim Akhtar , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.15 230/913] clocksource/drivers/exynos_mct: Handle DTS with higher number of interrupts Date: Tue, 5 Apr 2022 09:21:32 +0200 Message-Id: <20220405070346.750586466@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Krzysztof Kozlowski [ Upstream commit ab8da93dc06d82f464c47ab30e6c75190702f369 ] The driver statically defines maximum number of interrupts it can handle, however it does not respect that limit when configuring them. When provided with a DTS with more interrupts than assumed, the driver will overwrite static array mct_irqs leading to silent memory corruption. Validate the interrupts coming from DTS to avoid this. This does not change the fact that such DTS might not boot at all, because it is simply incompatible, however at least some warning will be printed. Fixes: 36ba5d527e95 ("ARM: EXYNOS: add device tree support for MCT controller driver") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Alim Akhtar Link: https://lore.kernel.org/r/20220220103815.135380-1-krzysztof.kozlowski@canonical.com Signed-off-by: Daniel Lezcano Signed-off-by: Sasha Levin --- drivers/clocksource/exynos_mct.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index 857cf12ebe57..cc2a961ddd3b 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -541,6 +541,11 @@ static int __init exynos4_timer_interrupts(struct device_node *np, * irqs are specified. */ nr_irqs = of_irq_count(np); + if (nr_irqs > ARRAY_SIZE(mct_irqs)) { + pr_err("exynos-mct: too many (%d) interrupts configured in DT\n", + nr_irqs); + nr_irqs = ARRAY_SIZE(mct_irqs); + } for (i = MCT_L0_IRQ; i < nr_irqs; i++) mct_irqs[i] = irq_of_parse_and_map(np, i); @@ -553,11 +558,14 @@ static int __init exynos4_timer_interrupts(struct device_node *np, mct_irqs[MCT_L0_IRQ], err); } else { for_each_possible_cpu(cpu) { - int mct_irq = mct_irqs[MCT_L0_IRQ + cpu]; + int mct_irq; struct mct_clock_event_device *pcpu_mevt = per_cpu_ptr(&percpu_mct_tick, cpu); pcpu_mevt->evt.irq = -1; + if (MCT_L0_IRQ + cpu >= ARRAY_SIZE(mct_irqs)) + break; + mct_irq = mct_irqs[MCT_L0_IRQ + cpu]; irq_set_status_flags(mct_irq, IRQ_NOAUTOEN); if (request_irq(mct_irq, -- 2.34.1