* [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check
@ 2021-01-18 11:36 Colin King
2021-01-20 9:57 ` Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Colin King @ 2021-01-18 11:36 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Dmitry Baryshkov, linux-arm-msm
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
There is an off-by-one array index bounds check on array
pmic_models. Fix this by checking using < rather than <= on
the array size.
Addresses-Coverity: ("Out-of-bounds read")
Fixes: 734c78e7febf ("soc: qcom: socinfo: add info from PMIC models array")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/soc/qcom/socinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index a985ed064669..f449df560d93 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -332,7 +332,7 @@ static int qcom_show_pmic_model_array(struct seq_file *seq, void *p)
unsigned int model = SOCINFO_MINOR(get_unaligned_le32(ptr + 2 * i * sizeof(u32)));
unsigned int die_rev = get_unaligned_le32(ptr + (2 * i + 1) * sizeof(u32));
- if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model])
+ if (model < ARRAY_SIZE(pmic_models) && pmic_models[model])
seq_printf(seq, "%s %u.%u\n", pmic_models[model],
SOCINFO_MAJOR(le32_to_cpu(die_rev)),
SOCINFO_MINOR(le32_to_cpu(die_rev)));
--
2.29.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
2021-01-18 11:36 [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Colin King
@ 2021-01-20 9:57 ` Dan Carpenter
2021-01-20 9:58 ` Dan Carpenter
2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
2 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2021-01-20 9:57 UTC (permalink / raw)
To: Andy Gross, Dmitry Baryshkov
Cc: Bjorn Andersson, Stephen Boyd, Sai Prakash Ranjan,
Douglas Anderson, linux-arm-msm, linux-kernel, kernel-janitors
These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
accessing one element beyond the end of the array.
Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/soc/qcom/socinfo.c | 2 +-
1 file changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index a985ed064669..5b4ad24a022b 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p)
if (model < 0)
return -EINVAL;
- if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model])
+ if (model < ARRAY_SIZE(pmic_models) && pmic_models[model])
seq_printf(seq, "%s\n", pmic_models[model]);
else
seq_printf(seq, "unknown (%d)\n", model);
--
2.29.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
@ 2021-01-20 9:57 ` Dan Carpenter
0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2021-01-20 9:57 UTC (permalink / raw)
To: Andy Gross, Dmitry Baryshkov
Cc: Bjorn Andersson, Stephen Boyd, Sai Prakash Ranjan,
Douglas Anderson, linux-arm-msm, linux-kernel, kernel-janitors
These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
accessing one element beyond the end of the array.
Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/soc/qcom/socinfo.c | 2 +-
1 file changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index a985ed064669..5b4ad24a022b 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p)
if (model < 0)
return -EINVAL;
- if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model])
+ if (model < ARRAY_SIZE(pmic_models) && pmic_models[model])
seq_printf(seq, "%s\n", pmic_models[model]);
else
seq_printf(seq, "unknown (%d)\n", model);
--
2.29.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check
2021-01-18 11:36 [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Colin King
@ 2021-01-20 9:58 ` Dan Carpenter
2021-01-20 9:58 ` Dan Carpenter
2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
2 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2021-01-20 9:58 UTC (permalink / raw)
To: Colin King
Cc: Andy Gross, Bjorn Andersson, Dmitry Baryshkov, linux-arm-msm,
kernel-janitors, linux-kernel
There was a second one introduced recently as well. I've sent a patch
for it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check
@ 2021-01-20 9:58 ` Dan Carpenter
0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2021-01-20 9:58 UTC (permalink / raw)
To: Colin King
Cc: Andy Gross, Bjorn Andersson, Dmitry Baryshkov, linux-arm-msm,
kernel-janitors, linux-kernel
There was a second one introduced recently as well. I've sent a patch
for it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
2021-01-20 9:57 ` Dan Carpenter
@ 2021-01-20 16:25 ` Doug Anderson
-1 siblings, 0 replies; 13+ messages in thread
From: Doug Anderson @ 2021-01-20 16:25 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Gross, Dmitry Baryshkov, Bjorn Andersson, Stephen Boyd,
Sai Prakash Ranjan, linux-arm-msm, LKML, kernel-janitors
Hi,
On Wed, Jan 20, 2021 at 1:58 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/soc/qcom/socinfo.c | 2 +-
> 1 file changed, 1 insertions(+), 1 deletions(-)
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
@ 2021-01-20 16:25 ` Doug Anderson
0 siblings, 0 replies; 13+ messages in thread
From: Doug Anderson @ 2021-01-20 16:25 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Gross, Dmitry Baryshkov, Bjorn Andersson, Stephen Boyd,
Sai Prakash Ranjan, linux-arm-msm, LKML, kernel-janitors
Hi,
On Wed, Jan 20, 2021 at 1:58 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/soc/qcom/socinfo.c | 2 +-
> 1 file changed, 1 insertions(+), 1 deletions(-)
Reviewed-by: Douglas Anderson <dianders@chromium.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
2021-01-20 9:57 ` Dan Carpenter
@ 2021-01-20 17:55 ` Dmitry Baryshkov
-1 siblings, 0 replies; 13+ messages in thread
From: Dmitry Baryshkov @ 2021-01-20 17:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Gross, Bjorn Andersson, Stephen Boyd, Sai Prakash Ranjan,
Douglas Anderson, open list:DRM DRIVER FOR MSM ADRENO GPU,
open list, kernel-janitors
On Wed, 20 Jan 2021 at 12:58, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
@ 2021-01-20 17:55 ` Dmitry Baryshkov
0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Baryshkov @ 2021-01-20 17:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Gross, Bjorn Andersson, Stephen Boyd, Sai Prakash Ranjan,
Douglas Anderson, open list:DRM DRIVER FOR MSM ADRENO GPU,
open list, kernel-janitors
On Wed, 20 Jan 2021 at 12:58, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
2021-01-20 9:57 ` Dan Carpenter
@ 2021-01-20 18:32 ` Stephen Boyd
-1 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2021-01-20 18:32 UTC (permalink / raw)
To: Andy Gross, Dan Carpenter, Dmitry Baryshkov
Cc: Bjorn Andersson, Sai Prakash Ranjan, Douglas Anderson,
linux-arm-msm, linux-kernel, kernel-janitors
Quoting Dan Carpenter (2021-01-20 01:57:55)
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
@ 2021-01-20 18:32 ` Stephen Boyd
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2021-01-20 18:32 UTC (permalink / raw)
To: Andy Gross, Dan Carpenter, Dmitry Baryshkov
Cc: Bjorn Andersson, Sai Prakash Ranjan, Douglas Anderson,
linux-arm-msm, linux-kernel, kernel-janitors
Quoting Dan Carpenter (2021-01-20 01:57:55)
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check
2021-01-18 11:36 [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Colin King
2021-01-20 9:57 ` Dan Carpenter
2021-01-20 9:58 ` Dan Carpenter
@ 2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
2 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-01-21 4:50 UTC (permalink / raw)
To: Colin King; +Cc: linux-arm-msm
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
On Mon, 18 Jan 2021 11:36:51 +0000 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There is an off-by-one array index bounds check on array
> pmic_models. Fix this by checking using < rather than <= on
> the array size.
>
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: 734c78e7febf ("soc: qcom: socinfo: add info from PMIC models array")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> [...]
Here is the summary with links:
- soc: qcom: socinfo: Fix off-by-one array index bounds check
https://git.kernel.org/qcom/c/e6393818c8d1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
2021-01-20 9:57 ` Dan Carpenter
` (3 preceding siblings ...)
(?)
@ 2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
-1 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-01-21 4:50 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-arm-msm
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
On Wed, 20 Jan 2021 12:57:55 +0300 you wrote:
> These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent
> accessing one element beyond the end of the array.
>
> Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/soc/qcom/socinfo.c | 2 +-
> 1 file changed, 1 insertions(+), 1 deletions(-)
Here is the summary with links:
- soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model()
https://git.kernel.org/qcom/c/5fb33d8960dc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-01-21 4:52 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 11:36 [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Colin King
2021-01-20 9:57 ` [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() Dan Carpenter
2021-01-20 9:57 ` Dan Carpenter
2021-01-20 16:25 ` Doug Anderson
2021-01-20 16:25 ` Doug Anderson
2021-01-20 17:55 ` Dmitry Baryshkov
2021-01-20 17:55 ` Dmitry Baryshkov
2021-01-20 18:32 ` Stephen Boyd
2021-01-20 18:32 ` Stephen Boyd
2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
2021-01-20 9:58 ` [PATCH] soc: qcom: socinfo: Fix off-by-one array index bounds check Dan Carpenter
2021-01-20 9:58 ` Dan Carpenter
2021-01-21 4:50 ` patchwork-bot+linux-arm-msm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.