All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
@ 2021-06-17 16:08 ` Tuan Phan
  0 siblings, 0 replies; 6+ messages in thread
From: Tuan Phan @ 2021-06-17 16:08 UTC (permalink / raw)
  Cc: Will Deacon, Mark Rutland, Robin Murphy, linux-arm-kernel, linux-kernel

When multiple dtcs share the same IRQ number, the irq_friend which
used to refer to dtc object gets calculated incorrect which leads
to invalid pointer.

Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
---
 drivers/perf/arm-cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 56a5c35..49016f2 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
 		irq = cmn->dtc[i].irq;
 		for (j = i; j--; ) {
 			if (cmn->dtc[j].irq == irq) {
-				cmn->dtc[j].irq_friend = j - i;
+				cmn->dtc[j].irq_friend = i - j;
 				goto next;
 			}
 		}
-- 
2.7.4


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

* [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
@ 2021-06-17 16:08 ` Tuan Phan
  0 siblings, 0 replies; 6+ messages in thread
From: Tuan Phan @ 2021-06-17 16:08 UTC (permalink / raw)
  Cc: Will Deacon, Mark Rutland, Robin Murphy, linux-arm-kernel, linux-kernel

When multiple dtcs share the same IRQ number, the irq_friend which
used to refer to dtc object gets calculated incorrect which leads
to invalid pointer.

Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
---
 drivers/perf/arm-cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 56a5c35..49016f2 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
 		irq = cmn->dtc[i].irq;
 		for (j = i; j--; ) {
 			if (cmn->dtc[j].irq == irq) {
-				cmn->dtc[j].irq_friend = j - i;
+				cmn->dtc[j].irq_friend = i - j;
 				goto next;
 			}
 		}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
  2021-06-17 16:08 ` Tuan Phan
@ 2021-06-17 17:48   ` Robin Murphy
  -1 siblings, 0 replies; 6+ messages in thread
From: Robin Murphy @ 2021-06-17 17:48 UTC (permalink / raw)
  To: Tuan Phan; +Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel

On 2021-06-17 17:08, Tuan Phan wrote:
> When multiple dtcs share the same IRQ number, the irq_friend which
> used to refer to dtc object gets calculated incorrect which leads
> to invalid pointer.

Oops, indeed this is supposed to be a forward offset *from* the previous 
match *to* the current dtc. It's almost as if I never managed to test 
it... :)

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
> 
> Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
> ---
>   drivers/perf/arm-cmn.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 56a5c35..49016f2 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
>   		irq = cmn->dtc[i].irq;
>   		for (j = i; j--; ) {
>   			if (cmn->dtc[j].irq == irq) {
> -				cmn->dtc[j].irq_friend = j - i;
> +				cmn->dtc[j].irq_friend = i - j;
>   				goto next;
>   			}
>   		}
> 

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

* Re: [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
@ 2021-06-17 17:48   ` Robin Murphy
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Murphy @ 2021-06-17 17:48 UTC (permalink / raw)
  To: Tuan Phan; +Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel

On 2021-06-17 17:08, Tuan Phan wrote:
> When multiple dtcs share the same IRQ number, the irq_friend which
> used to refer to dtc object gets calculated incorrect which leads
> to invalid pointer.

Oops, indeed this is supposed to be a forward offset *from* the previous 
match *to* the current dtc. It's almost as if I never managed to test 
it... :)

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
> 
> Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
> ---
>   drivers/perf/arm-cmn.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 56a5c35..49016f2 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
>   		irq = cmn->dtc[i].irq;
>   		for (j = i; j--; ) {
>   			if (cmn->dtc[j].irq == irq) {
> -				cmn->dtc[j].irq_friend = j - i;
> +				cmn->dtc[j].irq_friend = i - j;
>   				goto next;
>   			}
>   		}
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
  2021-06-17 16:08 ` Tuan Phan
@ 2021-06-17 22:38   ` Will Deacon
  -1 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2021-06-17 22:38 UTC (permalink / raw)
  To: Tuan Phan
  Cc: catalin.marinas, kernel-team, Will Deacon, linux-kernel,
	Mark Rutland, linux-arm-kernel, Robin Murphy

On Thu, 17 Jun 2021 09:08:49 -0700, Tuan Phan wrote:
> When multiple dtcs share the same IRQ number, the irq_friend which
> used to refer to dtc object gets calculated incorrect which leads
> to invalid pointer.
> 
> Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Applied to will (for-next/perf), thanks!

[1/1] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
      https://git.kernel.org/will/c/4e16f283edc2

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

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

* Re: [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
@ 2021-06-17 22:38   ` Will Deacon
  0 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2021-06-17 22:38 UTC (permalink / raw)
  To: Tuan Phan
  Cc: catalin.marinas, kernel-team, Will Deacon, linux-kernel,
	Mark Rutland, linux-arm-kernel, Robin Murphy

On Thu, 17 Jun 2021 09:08:49 -0700, Tuan Phan wrote:
> When multiple dtcs share the same IRQ number, the irq_friend which
> used to refer to dtc object gets calculated incorrect which leads
> to invalid pointer.
> 
> Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Applied to will (for-next/perf), thanks!

[1/1] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number
      https://git.kernel.org/will/c/4e16f283edc2

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-17 22:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 16:08 [PATCH] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number Tuan Phan
2021-06-17 16:08 ` Tuan Phan
2021-06-17 17:48 ` Robin Murphy
2021-06-17 17:48   ` Robin Murphy
2021-06-17 22:38 ` Will Deacon
2021-06-17 22:38   ` Will Deacon

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.