Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp152319rdd; Wed, 22 Nov 2023 11:51:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGR8MSOaxEgp75Nc+aa2T8zwlCzFdUEgVD+33sdLnNKrivH2Q3HZpM1cWAjKkg2TVk3w/c3 X-Received: by 2002:a05:6a00:7cf:b0:6c4:d6fa:ee9d with SMTP id n15-20020a056a0007cf00b006c4d6faee9dmr543065pfu.1.1700682690613; Wed, 22 Nov 2023 11:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700682690; cv=none; d=google.com; s=arc-20160816; b=Tx7uUOrjDMuumnrLXnOBOWYfvDGNvcNsmkgQLwYL6kE/ZkTNloZMvEst+aZu4NfsDc 1nMIKlnnvCqhG9k0YYQnLCuAVN9K60DaaGnealr//alLDmX40NakeAzOzpPbezw6kp9f h89HIkJ8jY8bFO5JVEKRaCw754RIqaOBP2NliETI1gr43XRKEUPTOgkNj5oTuBC64JHZ fJeToXbDsmwXLyL2dllFwDKudsiHCAui+hNWfwtNMTVd65zuUUCLuhST3U0BxAHf975j x0I9SJy8e9a5rLe9AVew5ohKpNWUFj+9/0OKkuNmOCgJ5G0jyQaUEtVezNiWsjfaWKTL qWtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=/bsx4WnauLYEe7yItSDbD8J4BwUhf/mRLFENlCXMgeI=; fh=1qDXOl4lofDT6eq/9fFKL4+sMA1l0qG5bFCMoR3L5SQ=; b=EHBPEzEFawGamCHBuvCZulKIRWnYP2ObNM0REEfx2eqqWLl+cwpvbkZNqhheeFtiiP PiE7Xy4jMVtX0KAb3LIwwaY2aleLBaee4jAZaA3R9li3+vP8hfhcimgcBFLk7PCbIuBA gw/7N1CsiaMtu7HC3Z0qD78fDygelu0oGolaPctP92C6z4KeYPvv+IOQt0Ia5jsKCAqb 9YATFmA0buBsw0KDTVJo1HXpMn3myrMBtvVV/QD1BCR3izGRxzyjq6XpRx4Uy+YMWwfq 323zrJ1JMv6I1hifQX3JLacyQUinGJ0nS8h1Yfj6t5DdcX8vm9yOsQ8FYbWlvm6SH2gn LCUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id k1-20020a056a00134100b006c4d5ca7fe7si195317pfu.366.2023.11.22.11.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 11:51:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3B396816EBF0; Wed, 22 Nov 2023 11:50:52 -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 S234357AbjKVTun convert rfc822-to-8bit (ORCPT + 99 others); Wed, 22 Nov 2023 14:50:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjKVTui (ORCPT ); Wed, 22 Nov 2023 14:50:38 -0500 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A57BAD45; Wed, 22 Nov 2023 11:50:32 -0800 (PST) Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-1f92cc9b2c5so14869fac.1; Wed, 22 Nov 2023 11:50:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700682632; x=1701287432; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i13eRCRuzIPfY/WqVtCzJrgnUD1kwRhCgNmFzwsG9Jo=; b=EqltRsny2ys42NR3GpDjB9nf0+/MKL5xt1jwvyQTripRBwwoq/el64XZHTuI3EkTOh Sq89DPpyEk5doe9QtrlBqq9ng7uP0FbOeczUSJUEl3GQ+hY2Hli56od2tp+FvV/eui+V KlF2evsl4vVsr/DWnbN/ShzmWeYUCzCKTJegFWXLmO77CjTuROhXu94R4R0up2ASKLrO P/uGOLgFAmjsBD20X61CcwHFonmEftqQBEWkzkdysak4UXMlfh2sOY8RahngmSIu8ccQ L6Ch5ZA2NYmffzsxWHfvMwiXZE8BENfhdiYA8UgsSpLYXpam/Z7JQkpcoAzvuOV/Yp2f 9Y4Q== X-Gm-Message-State: AOJu0YwV/sj+DKzWw5DpNUIxqoDu1mTpYMzSd8cYUNHanvgvPsyHaWst v7bnqo4EpylSwc6rzu1lY+VnLpaSNRA5IgLWCgI= X-Received: by 2002:a05:6870:2401:b0:1f9:5d11:cc7a with SMTP id n1-20020a056870240100b001f95d11cc7amr4006681oap.3.1700682631827; Wed, 22 Nov 2023 11:50:31 -0800 (PST) MIME-Version: 1.0 References: <430a1271-a45c-4f5a-90c7-a62703ac7cf4@ancud.ru> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 22 Nov 2023 20:50:20 +0100 Message-ID: Subject: Re: [PATCH] ACPI: LPIT: fix u32 multiplication overflow To: Nikita Kiryushin Cc: "Rafael J. Wysocki" , Len Brown , Srinivas Pandruvada , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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:50:52 -0800 (PST) On Wed, Nov 22, 2023 at 8:41 PM Nikita Kiryushin wrote: > > 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); > > ) OK, fair enough. > Not sure about the math above, but it seemed reasonable enough to me to > switch to overflow-resilient arithmetic here.