All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf
@ 2017-12-13 22:45 Gustavo A. R. Silva
  2017-12-15 18:18 ` George Cherian
  2017-12-16  1:47 ` Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-12-13 22:45 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, George Cherian
  Cc: linux-acpi, linux-kernel, Gustavo A. R. Silva

If pcc_ss_id is less than 0, there is a negative array index read
before verifying pcc_ss_id is not a negative value.

Fix this by removing the code that triggers this issue.

Notice that this code is already properly placed after the check
on pcc_ss_id at line 1182: pcc_ss_data = pcc_data[pcc_ss_id];

Addresses-Coverity-ID: 1426090 ("Negative array index read")
Fixes: 1ecbd7170d65 ("ACPI / CPPC: Fix KASAN global out of bounds warning")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/acpi/cppc_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 30e84cc..06ea474 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1171,7 +1171,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
 	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
 	struct cpc_register_resource *desired_reg;
 	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
-	struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id];
+	struct cppc_pcc_data *pcc_ss_data;
 	int ret = 0;
 
 	if (!cpc_desc || pcc_ss_id < 0) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf
  2017-12-13 22:45 [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf Gustavo A. R. Silva
@ 2017-12-15 18:18 ` George Cherian
  2017-12-16  1:47 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: George Cherian @ 2017-12-15 18:18 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Rafael J. Wysocki, Len Brown, George Cherian
  Cc: linux-acpi, linux-kernel



On Thursday 14 December 2017 04:15 AM, Gustavo A. R. Silva wrote:
> If pcc_ss_id is less than 0, there is a negative array index read
> before verifying pcc_ss_id is not a negative value.
>
> Fix this by removing the code that triggers this issue.
>
> Notice that this code is already properly placed after the check
> on pcc_ss_id at line 1182: pcc_ss_data = pcc_data[pcc_ss_id];
>
> Addresses-Coverity-ID: 1426090 ("Negative array index read")
> Fixes: 1ecbd7170d65 ("ACPI / CPPC: Fix KASAN global out of bounds warning")

Reviewed-by: George Cherian <george.cherian@cavium.com>


> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>   drivers/acpi/cppc_acpi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 30e84cc..06ea474 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1171,7 +1171,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
>   	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
>   	struct cpc_register_resource *desired_reg;
>   	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
> -	struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id];
> +	struct cppc_pcc_data *pcc_ss_data;
>   	int ret = 0;
>   
>   	if (!cpc_desc || pcc_ss_id < 0) {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf
  2017-12-13 22:45 [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf Gustavo A. R. Silva
  2017-12-15 18:18 ` George Cherian
@ 2017-12-16  1:47 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2017-12-16  1:47 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Len Brown, George Cherian, linux-acpi, linux-kernel

On Wednesday, December 13, 2017 11:45:41 PM CET Gustavo A. R. Silva wrote:
> If pcc_ss_id is less than 0, there is a negative array index read
> before verifying pcc_ss_id is not a negative value.
> 
> Fix this by removing the code that triggers this issue.
> 
> Notice that this code is already properly placed after the check
> on pcc_ss_id at line 1182: pcc_ss_data = pcc_data[pcc_ss_id];
> 
> Addresses-Coverity-ID: 1426090 ("Negative array index read")
> Fixes: 1ecbd7170d65 ("ACPI / CPPC: Fix KASAN global out of bounds warning")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/acpi/cppc_acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 30e84cc..06ea474 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1171,7 +1171,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
>  	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
>  	struct cpc_register_resource *desired_reg;
>  	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
> -	struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id];
> +	struct cppc_pcc_data *pcc_ss_data;
>  	int ret = 0;
>  
>  	if (!cpc_desc || pcc_ss_id < 0) {
> 

I applied a patch from Coling Ian King that did the same thing and was
posted eaelier.

Thanks,
Rafael



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-16  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 22:45 [PATCH] ACPI / CPPC: Fix negative array index read in cppc_set_perf Gustavo A. R. Silva
2017-12-15 18:18 ` George Cherian
2017-12-16  1:47 ` Rafael J. Wysocki

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.