From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Dmitry Kandybka <d.kandybka@gmail.com>
Cc: Rajneesh Bhardwaj <irenic.rajneesh@gmail.com>,
David E Box <david.e.box@intel.com>,
Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
Date: Fri, 20 Dec 2024 13:28:14 +0200 (EET) [thread overview]
Message-ID: <d4be773d-a2fe-686c-8769-800a309e5783@linux.intel.com> (raw)
In-Reply-To: <20241219232045.51792-1-d.kandybka@gmail.com>
On Fri, 20 Dec 2024, Dmitry Kandybka wrote:
> In pmc_core_ltr_show(), promote 'val' to 'u64' to avoid possible integer
> overflow. Values (10 bit) are multiplied by the scale, the result of
> expression is in a range from 1 to 34,326,183,936 which is bigger then
> UINT32_MAX. Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
> ---
> drivers/platform/x86/intel/pmc/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
> index 3e7f99ac8c94..f06ba9636b03 100644
> --- a/drivers/platform/x86/intel/pmc/core.c
> +++ b/drivers/platform/x86/intel/pmc/core.c
> @@ -660,12 +660,12 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
> if (FIELD_GET(LTR_REQ_NONSNOOP, ltr_raw_data)) {
> scale = FIELD_GET(LTR_DECODED_SCALE, nonsnoop_ltr);
> val = FIELD_GET(LTR_DECODED_VAL, nonsnoop_ltr);
> - decoded_non_snoop_ltr = val * convert_ltr_scale(scale);
> + decoded_non_snoop_ltr = (u64)val * convert_ltr_scale(scale);
> }
> if (FIELD_GET(LTR_REQ_SNOOP, ltr_raw_data)) {
> scale = FIELD_GET(LTR_DECODED_SCALE, snoop_ltr);
> val = FIELD_GET(LTR_DECODED_VAL, snoop_ltr);
> - decoded_snoop_ltr = val * convert_ltr_scale(scale);
> + decoded_snoop_ltr = (u64)val * convert_ltr_scale(scale);
Please change val to u64 instead so casting won't be necessary.
--
i.
prev parent reply other threads:[~2024-12-20 11:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 23:20 [PATCH] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show() Dmitry Kandybka
2024-12-20 11:28 ` Ilpo Järvinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4be773d-a2fe-686c-8769-800a309e5783@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=d.kandybka@gmail.com \
--cc=david.e.box@intel.com \
--cc=hdegoede@redhat.com \
--cc=irenic.rajneesh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox