Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp147863rdd; Wed, 22 Nov 2023 11:42:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJQnCgABtpvJza4vN1ZQtql05cwUr+tcdk980+torQw7cj4EYLMaiIuoBL4C7Bm5N+dL/Q X-Received: by 2002:a05:6a00:124f:b0:6cb:4bfb:23e1 with SMTP id u15-20020a056a00124f00b006cb4bfb23e1mr3389059pfi.23.1700682158495; Wed, 22 Nov 2023 11:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700682158; cv=none; d=google.com; s=arc-20160816; b=UsS2K46P77Xp0uUtZyeNK90PbCZk5JWjMSMH7HmoY3MOXH7b28AVC9R/jukwwD/iBE nMbeJNfpJOLiaAcR6UII4PePRE8ey0Hbwl6BvvSk6Me+CHdUuBZb2SqQfPELTFJDj318 IDsLg+EuCmi6w0BNE9kD6cAQ70yLrOGOc1JlE9IWFdnIbcWsTAkreQ2lQ0SudBIozmKd YqjySi+7uHRNk/5z1Znhm4SlqiuaZFnZTtsJcS29gnh4+BWycMnVexXLvklJ1s/dDDhv hX4v/MYq3u0geJFgL6mpJ8KyCxDcUdcye04DRljeCDCK9TwOgyP4HaQSnJawIBOunsTN 0Pdg== 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=Mgop0IuThK9QSkh8owAieDGufYnrtVz4XhkK4TyMq24=; fh=lwgto5dPFEWoYNQTiWX9fbaxzWBM6YuPo0/1akwU8Vc=; b=CCk1cCf7ns6H9ljr0m3YZiENLM2cnIvLZKTqOcO6/aaUi0KjISMcaRWonMD3X/WsFy bq9pcab5C9N8zWDbTFxEQi/ahr1/FXgzRPCUbtsiJrM3RxY1khwHUf7jJZe8WMtEwNWn WgtA1tmB084uZ72w36ie3DuDI85ui7sz+vb44Wq72iSEaQT1ms+Wu4WTXN9BBBt44/9F eOSHLFoN8kkNFsR/9sGEYU27jqQAQIzxw3QAiIJ+yz50m5MpxffgvLscP+LSoR2HHSDM hmaUEeSAVtODq1OKY4V9VnmsrY9cQQkg/u9LXWOd7fKk2GShDWCOkIzpkIJPqxft6LlD qoqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y13-20020aa79e0d000000b0068e3efffe2csi157537pfq.243.2023.11.22.11.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 11:42:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2590D80465F7; Wed, 22 Nov 2023 11:41:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbjKVTlH (ORCPT + 99 others); Wed, 22 Nov 2023 14:41:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbjKVTlF (ORCPT ); Wed, 22 Nov 2023 14:41:05 -0500 Received: from relay163.nicmail.ru (relay163.nicmail.ru [91.189.117.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 597F898; Wed, 22 Nov 2023 11:40:55 -0800 (PST) Received: from [10.28.138.152] (port=30158 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1r5t5f-00080N-BL; Wed, 22 Nov 2023 22:40:51 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1104.mail.hosting.nic.ru (Exim 5.55) with id 1r5t5f-00FEPt-1S; Wed, 22 Nov 2023 22:40:51 +0300 Message-ID: Date: Wed, 22 Nov 2023 22:40:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ACPI: LPIT: fix u32 multiplication overflow Content-Language: en-US To: "Rafael J. Wysocki" Cc: Len Brown , Srinivas Pandruvada , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org References: <430a1271-a45c-4f5a-90c7-a62703ac7cf4@ancud.ru> From: Nikita Kiryushin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-MS-Exchange-Organization-SCL: -1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 11:41:14 -0800 (PST) My reasoning was around something like: 1) tsc_khz is declared as unsigned int tsc_khz; 2) tsc_khz * 1000 would overflow, if the result is larger, than an unsigned int could hold; 3) given tsc_khz * 1000 > UINT_MAX is bad, tsc_khz > UINT_MAX / 1000 is bad; 4) if UINT_MAX is 4294967295, than tsc_khz > 4294967.295 is bad, for example 4294968 would lead to overflow; 5) 4294968 kHz is 4294.968 MHz, which seems realistically high to me. For me, tsc: Refined TSC clocksource calibration: 3393.624 MHz (seems like, it is derived from the same value, pr_info("Refined TSC clocksource calibration: %lu.%03lu MHz\n",         (unsigned long)tsc_khz / 1000,         (unsigned long)tsc_khz % 1000); ) Not sure about the math above, but it seemed reasonable enough to me to switch to overflow-resilient arithmetic here. On 11/21/23 23:14, Rafael J. Wysocki wrote: > On Tue, Nov 21, 2023 at 8:56 PM Rafael J. Wysocki wrote: > That should be "hundreds of thousands of kHz", so I was mistaken. > > But anyway: > >> Why is it really a concern? >>