All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/arm-cmn: Fix filter_sel lookup
@ 2022-05-10 21:23 Robin Murphy
  2022-05-11  9:32 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Robin Murphy @ 2022-05-10 21:23 UTC (permalink / raw)
  To: will; +Cc: mark.rutland, linux-arm-kernel, Qian Cai

Carefully considering the bounds of an array is all well and good,
until you forget that that array also contains a NULL sentinel at
the end and dereference it. So close...

Reported-by: Qian Cai <quic_qiancai@quicinc.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.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 15586bbec2f7..282d2f874ec1 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -1514,7 +1514,7 @@ static enum cmn_filter_select arm_cmn_filter_sel(enum cmn_model model,
 	struct arm_cmn_event_attr *e;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(arm_cmn_event_attrs); i++) {
+	for (i = 0; i < ARRAY_SIZE(arm_cmn_event_attrs) - 1; i++) {
 		e = container_of(arm_cmn_event_attrs[i], typeof(*e), attr.attr);
 		if (e->model & model && e->type == type && e->eventid == eventid)
 			return e->fsel;
-- 
2.35.3.dirty


_______________________________________________
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] 2+ messages in thread

* Re: [PATCH] perf/arm-cmn: Fix filter_sel lookup
  2022-05-10 21:23 [PATCH] perf/arm-cmn: Fix filter_sel lookup Robin Murphy
@ 2022-05-11  9:32 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2022-05-11  9:32 UTC (permalink / raw)
  To: Robin Murphy
  Cc: catalin.marinas, kernel-team, Will Deacon, mark.rutland,
	Qian Cai, linux-arm-kernel

On Tue, 10 May 2022 22:23:08 +0100, Robin Murphy wrote:
> Carefully considering the bounds of an array is all well and good,
> until you forget that that array also contains a NULL sentinel at
> the end and dereference it. So close...
> 
> 

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

[1/1] perf/arm-cmn: Fix filter_sel lookup
      https://git.kernel.org/will/c/3630b2a86390

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] 2+ messages in thread

end of thread, other threads:[~2022-05-11  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 21:23 [PATCH] perf/arm-cmn: Fix filter_sel lookup Robin Murphy
2022-05-11  9:32 ` 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.