* [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
@ 2025-01-23 22:07 Dmitry Kandybka
2025-01-23 22:10 ` Rajneesh Bhardwaj
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dmitry Kandybka @ 2025-01-23 22:07 UTC (permalink / raw)
To: Rajneesh Bhardwaj
Cc: David E Box, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel, lvc-project
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>
---
v1 -> v2: 'val' variable declared as 'u64' instead of type casting
at usage points
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 10f04b944117..1ee0fb5f8250 100644
--- a/drivers/platform/x86/intel/pmc/core.c
+++ b/drivers/platform/x86/intel/pmc/core.c
@@ -626,8 +626,8 @@ static u32 convert_ltr_scale(u32 val)
static int pmc_core_ltr_show(struct seq_file *s, void *unused)
{
struct pmc_dev *pmcdev = s->private;
- u64 decoded_snoop_ltr, decoded_non_snoop_ltr;
- u32 ltr_raw_data, scale, val;
+ u64 decoded_snoop_ltr, decoded_non_snoop_ltr, val;
+ u32 ltr_raw_data, scale;
u16 snoop_ltr, nonsnoop_ltr;
unsigned int i, index, ltr_index = 0;
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
2025-01-23 22:07 [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show() Dmitry Kandybka
@ 2025-01-23 22:10 ` Rajneesh Bhardwaj
2025-01-24 8:04 ` Ilpo Järvinen
2025-01-28 12:20 ` Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Rajneesh Bhardwaj @ 2025-01-23 22:10 UTC (permalink / raw)
To: Dmitry Kandybka
Cc: David E Box, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel, lvc-project
Looks good to me.
Reviewed-by: Rajneesh Bhardwaj <irenic.rajneesh@gmail.com>
On Thu, Jan 23, 2025 at 5:07 PM Dmitry Kandybka <d.kandybka@gmail.com> 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>
> ---
> v1 -> v2: 'val' variable declared as 'u64' instead of type casting
> at usage points
>
> 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 10f04b944117..1ee0fb5f8250 100644
> --- a/drivers/platform/x86/intel/pmc/core.c
> +++ b/drivers/platform/x86/intel/pmc/core.c
> @@ -626,8 +626,8 @@ static u32 convert_ltr_scale(u32 val)
> static int pmc_core_ltr_show(struct seq_file *s, void *unused)
> {
> struct pmc_dev *pmcdev = s->private;
> - u64 decoded_snoop_ltr, decoded_non_snoop_ltr;
> - u32 ltr_raw_data, scale, val;
> + u64 decoded_snoop_ltr, decoded_non_snoop_ltr, val;
> + u32 ltr_raw_data, scale;
> u16 snoop_ltr, nonsnoop_ltr;
> unsigned int i, index, ltr_index = 0;
>
> --
> 2.47.1
>
--
Thanks,
Rajneesh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
2025-01-23 22:07 [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show() Dmitry Kandybka
2025-01-23 22:10 ` Rajneesh Bhardwaj
@ 2025-01-24 8:04 ` Ilpo Järvinen
2025-01-28 12:20 ` Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2025-01-24 8:04 UTC (permalink / raw)
To: Dmitry Kandybka
Cc: Rajneesh Bhardwaj, David E Box, Hans de Goede,
platform-driver-x86, LKML, lvc-project
[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]
On Fri, 24 Jan 2025, 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>
> ---
> v1 -> v2: 'val' variable declared as 'u64' instead of type casting
> at usage points
>
> 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 10f04b944117..1ee0fb5f8250 100644
> --- a/drivers/platform/x86/intel/pmc/core.c
> +++ b/drivers/platform/x86/intel/pmc/core.c
> @@ -626,8 +626,8 @@ static u32 convert_ltr_scale(u32 val)
> static int pmc_core_ltr_show(struct seq_file *s, void *unused)
> {
> struct pmc_dev *pmcdev = s->private;
> - u64 decoded_snoop_ltr, decoded_non_snoop_ltr;
> - u32 ltr_raw_data, scale, val;
> + u64 decoded_snoop_ltr, decoded_non_snoop_ltr, val;
> + u32 ltr_raw_data, scale;
> u16 snoop_ltr, nonsnoop_ltr;
> unsigned int i, index, ltr_index = 0;
Thanks for the update,
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
2025-01-23 22:07 [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show() Dmitry Kandybka
2025-01-23 22:10 ` Rajneesh Bhardwaj
2025-01-24 8:04 ` Ilpo Järvinen
@ 2025-01-28 12:20 ` Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2025-01-28 12:20 UTC (permalink / raw)
To: Rajneesh Bhardwaj, Dmitry Kandybka
Cc: David E Box, Hans de Goede, platform-driver-x86, linux-kernel,
lvc-project
On Fri, 24 Jan 2025 01:07:39 +0300, 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.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show()
commit: 4afd0e58a6793b8e4d78cb55dbcf6279936730e5
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-28 12:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23 22:07 [PATCH v2] platform/x86/intel: pmc: fix ltr decode in pmc_core_ltr_show() Dmitry Kandybka
2025-01-23 22:10 ` Rajneesh Bhardwaj
2025-01-24 8:04 ` Ilpo Järvinen
2025-01-28 12:20 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox