From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23734D3C547 for ; Sat, 19 Oct 2024 06:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:CC:To: Subject:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C+/lWFqelfLumg8bwlqYFMs+WqC58jSJHAL39/mWjSk=; b=DEsLFjgFGyD/emJTyGItbFkosF mbm/B1lX5fmS+x9NrXBkNqCXpDMbhfNErfd9JZcq96iWiFVqQhMSMTBXL/P+ofX183V6QnRxfGBLZ gXOx0fc/ldjhGAQl3esvWVF0kzGViMr8/tCPxvSHu77ek1ctRihFEGrQ3c+Z1xo3rcI8SW2Psg28F uRJmaOJv2m3FQcIqpey2cgIgGLUi4qAEXR/Uo5t2wD2oGRBkXbrGa0+g4vt834PyxTx13XCW7fRq0 1LwVCjVxJvu5KJE46rjgxhfVpJXeDEe2bUY8QbwdPnUwTgPHXsLh0gstEzGW8ljOE1fM2s7cdm6c0 EluflBMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t23B9-00000002fzA-1Xj9; Sat, 19 Oct 2024 06:43:11 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t239X-00000002fp2-1VzT for linux-arm-kernel@lists.infradead.org; Sat, 19 Oct 2024 06:41:34 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4XVsPp0ZVhz1SCpM; Sat, 19 Oct 2024 14:39:58 +0800 (CST) Received: from dggpemf500002.china.huawei.com (unknown [7.185.36.57]) by mail.maildlp.com (Postfix) with ESMTPS id 7FFF41A0188; Sat, 19 Oct 2024 14:41:16 +0800 (CST) Received: from [10.174.178.247] (10.174.178.247) by dggpemf500002.china.huawei.com (7.185.36.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 19 Oct 2024 14:41:15 +0800 Subject: Re: [PATCH v4] ACPI: GTDT: Tighten the check for the array of platform timer structures To: Zheng Zengkai , , , , , , CC: , , , , References: <20241016095458.34126-1-zhengzengkai@huawei.com> From: Hanjun Guo Message-ID: Date: Sat, 19 Oct 2024 14:41:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20241016095458.34126-1-zhengzengkai@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.247] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemf500002.china.huawei.com (7.185.36.57) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241018_234132_543740_4D928A8A X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024/10/16 17:54, Zheng Zengkai wrote: > As suggested by Marc and Lorenzo, first we need to check whether the > platform_timer entry pointer is within gtdt bounds (< gtdt_end) before > de-referencing what it points at to detect the length of the platform > timer struct and then check that the length of current platform_timer > struct is also valid, i.e. the length is not zero and within gtdt_end. > Now next_platform_timer() only checks against gtdt_end for the entry of > subsequent platform timer without checking the length of it and will > not report error if the check failed and the existing check in function > acpi_gtdt_init() is also not enough. > > Modify the for_each_platform_timer() iterator and use it combined with > a dedicated check function platform_timer_valid() to do the check > against table length (gtdt_end) for each element of platform timer > array in function acpi_gtdt_init(), making sure that both their entry > and length actually fit in the table. > > Suggested-by: Lorenzo Pieralisi > Co-developed-by: Marc Zyngier > Signed-off-by: Marc Zyngier Nit: since there is a "Co-developed-by:" for Marc, the "Signed-off-by:" can be removed. The rest of the patch looks good to me. I did a test again Kunpeng ARM sever and no regressions, hopefully will not trigger firmware bugs for other platforms. Reviewed-by: Hanjun Guo Tested-by: Hanjun Guo Thanks Hanjun