From nobody Thu Apr 2 20:53:05 2026 Received: from mail.crpt.ru (mail.crpt.ru [91.236.205.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4830727BF7C; Fri, 13 Feb 2026 06:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.236.205.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770964216; cv=none; b=sqxizZSIWio5l500/M+fETWl5a6cPfZfahLLhb7QKeImzOrDUvOYHDYWAHNwcfBwQfHDcROzI8iLWymx3Fer4lYvUKA+0ef8FRtZXVgk1DWGF6Db2p+kKvcVQj6uvkO46SCpfSsFPf1O/HsWHv2xsl7kz6svjypGY1rX4ClkSzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770964216; c=relaxed/simple; bh=wV7DAzzqNuCCfLN5M5sE1fU0bi1iDDxhi3lmyRlyVUA=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=K+2L66n1vbuD2Xvefa/VBDiJ0wTy1kI0CVUFhTn2ykvZHbiEKc9R1SlR2PKHLx5rc55sqRIfcmupAVXcFxJOdZ5zacnpgGFJbHui3YqNZngkbAOO6cODimr/RUQ1cJIpsMqDO0CP1M6XZ8SGkJAgt8AJuFmxQ55QfFd7DcEclG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=crpt.ru; spf=pass smtp.mailfrom=crpt.ru; dkim=pass (2048-bit key) header.d=crpt.ru header.i=@crpt.ru header.b=JuV+mcgb; arc=none smtp.client-ip=91.236.205.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=crpt.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crpt.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=crpt.ru header.i=@crpt.ru header.b="JuV+mcgb" Received: from mail.crpt.ru ([192.168.60.4]) by mail.crpt.ru with ESMTPS id 61D6THmr005781-61D6THmt005781 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=OK); Fri, 13 Feb 2026 09:29:17 +0300 Received: from EX2.crpt.local (192.168.60.4) by ex2.crpt.local (192.168.60.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Fri, 13 Feb 2026 09:29:16 +0300 Received: from EX2.crpt.local ([192.168.60.4]) by EX2.crpt.local ([192.168.60.4]) with mapi id 15.01.2507.044; Fri, 13 Feb 2026 09:29:16 +0300 From: =?utf-8?B?0JLQsNGC0L7RgNC+0L/QuNC9INCQ0L3QtNGA0LXQuQ==?= To: "Rafael J. Wysocki" CC: =?utf-8?B?0JLQsNGC0L7RgNC+0L/QuNC9INCQ0L3QtNGA0LXQuQ==?= , Jacob Pan , Ajay Thomas , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" , "stable@vger.kernel.org" Subject: [PATCH] powercap: intel_rapl: use unsigned arithmetic in time window computation Thread-Topic: [PATCH] powercap: intel_rapl: use unsigned arithmetic in time window computation Thread-Index: AQHcnLITgGace02fqUu09hbfrEIEfA== Date: Fri, 13 Feb 2026 06:29:16 +0000 Message-ID: <20260213062542.169365-1-a.vatoropin@crpt.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-kse-serverinfo: EX2.crpt.local, 9 x-kse-antivirus-interceptor-info: scan successful x-kse-antivirus-info: Clean, bases: 2/12/2026 10:40:00 PM x-kse-attachment-filter-triggered-rules: Clean x-kse-attachment-filter-triggered-filters: Clean x-kse-bulkmessagesfiltering-scan-result: protection disabled Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FEAS-BEC-Info: WlpIGw0aAQkEARIJHAEHBlJSCRoLAAEeDUhZUEhYSFhIWUhZXkguLVxYWC48UVlRWFhYWVxaSFlRSAlGHgkcBxoHGAEGKAsaGBxGGh1IWUhZX0gaCQ4JDQQoAw0aBg0ERgcaD0hYSFpIWVpIWVFaRlleUEZeWEZcSFBIWEhYSF1IWEhYSFhIXFhICQIJEUYcAAcFCRtGDAkeAQxGGgkCCQUJBgELAwkFKAEGHA0ERgsHBUhYSFpRSAIJCwcKRgIdBkYYCQYoBAEGHRBGAQYcDQRGCwcFSFhIWlBIBAEGHRBFAw0aBg0EKB4PDRpGAw0aBg0ERgcaD0hYSFpQSAQeC0UYGgcCDQscKAQBBh0QHA0bHAEGD0YHGg9IWEhZX0gaCQ4JDQQoAw0aBg0ERgcaD0hY X-FEAS-Client-IP: 192.168.60.4 X-FE-Policy-ID: 2:4:0:SYSTEM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=crpt.ru; s=crpt.ru; c=relaxed/relaxed; h=from:to:cc:subject:date:message-id:content-type:mime-version; bh=wV7DAzzqNuCCfLN5M5sE1fU0bi1iDDxhi3lmyRlyVUA=; b=JuV+mcgbnaq2toX2ekMlgl00Ln+BIqOpMHmI34HGVvFixqeg5COrjPt/Pb3PCw9O1M9KFPVyABc5 d1anSOFCH3yZ4J6IygwWKWAUCfKx/uOFTvznFFJMNDpbVhwTHD//v94Dt0tz+VcUBeYER1Q2++iU 4XKtadULpTSZ6BQW42fWGroOii5KEHVviDAlYZnwmH4zCJLnMSi8eI6BuoswaQyeMyr4lguzJjZc 00IZTK40FpiJkLPNUo+BlLvd6YogWqAXbR+jEFXzvQDZRvkci5GCXnoXefktoA0lNC+3cPNWBpf3 dfO/W2Id5jvWnPws2tYPPd2Majy4R7YM1U1kLQ== From: Andrey Vatoropin In rapl_compute_time_window_core() the time window is calculated using the variable "y". This variable is limited by the mask 0x1F, however=C2=A0the result of the corner-case expression (1 << 0x1F) is 0x80000000 of signed integer type. Actually it's undefined in standard C language but the kernel is compiled with -fno-strict-overflow (-fwrapv) flag which does the trick. Eventually the unexpected sign extension is possible when the result of type int is expanded to u64, like 0x80000000 -> 0xFFFFFFFF80000000 which leads to incorrect arithmetic. Avoid sign extension by casting the left operand of the shift to the unsigned type before performing the shift. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3c2c08454ce9 ("powercap / RAPL: handle atom and core differences") Cc: stable@vger.kernel.org Signed-off-by: Andrey Vatoropin --- drivers/powercap/intel_rapl_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_= rapl_common.c index 3ff6da3bf4e6..0f2d3d1a00c5 100644 --- a/drivers/powercap/intel_rapl_common.c +++ b/drivers/powercap/intel_rapl_common.c @@ -1107,7 +1107,7 @@ static u64 rapl_compute_time_window_core(struct rapl_= domain *rd, u64 value, if (!to_raw) { f =3D (value & 0x60) >> 5; y =3D value & 0x1f; - value =3D (1 << y) * (4 + f) * rd->time_unit / 4; + value =3D (1U << y) * (4 + f) * rd->time_unit / 4; } else { if (value < rd->time_unit) return 0; --=20 2.43.0