linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] stm class: Fix out of bound access from bitmap allocation
@ 2019-04-05 12:22 Sai Prakash Ranjan
  2019-04-05 13:14 ` David Laight
  2019-04-16 15:00 ` Alexander Shishkin
  0 siblings, 2 replies; 9+ messages in thread
From: Sai Prakash Ranjan @ 2019-04-05 12:22 UTC (permalink / raw)
  To: Alexander Shishkin, Greg Kroah-Hartman, Mulu He, Tingwei Zhang,
	Maxime Coquelin, Alexandre Torgue, linux-stm32, Mathieu Poirier,
	Suzuki K Poulose, Mike Leach, Leo Yan
  Cc: Sai Prakash Ranjan, Rajendra Nayak, linux-arm-msm, linux-kernel,
	stable, Sibi Sankar, Vivek Gautam, linux-arm-kernel

From: Mulu He <muluhe@codeaurora.org>

Bitmap allocation works on array of unsigned longs and
for stm master allocation when the number of software
channels is 32, 4 bytes are allocated and there is a out of
bound access at the first 8 bytes access of bitmap region.

Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Mulu He <muluhe@codeaurora.org>
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
Cc: stable@vger.kernel.org
---
 drivers/hwtracing/stm/core.c | 2 +-
 drivers/hwtracing/stm/stm.h  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 93ce3aa740a9..21a5838f6e67 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -168,7 +168,7 @@ static int stp_master_alloc(struct stm_device *stm, unsigned int idx)
 	struct stp_master *master;
 	size_t size;
 
-	size = ALIGN(stm->data->sw_nchannels, 8) / 8;
+	size = ALIGN(stm->data->sw_nchannels, STM_MASTER_SZ) / STM_MASTER_SZ;
 	size += sizeof(struct stp_master);
 	master = kzalloc(size, GFP_ATOMIC);
 	if (!master)
diff --git a/drivers/hwtracing/stm/stm.h b/drivers/hwtracing/stm/stm.h
index 3569439d53bb..10eac550c75f 100644
--- a/drivers/hwtracing/stm/stm.h
+++ b/drivers/hwtracing/stm/stm.h
@@ -12,6 +12,8 @@
 
 #include <linux/configfs.h>
 
+#define STM_MASTER_SZ sizeof(unsigned long)
+
 struct stp_policy;
 struct stp_policy_node;
 struct stm_protocol_driver;
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


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

end of thread, other threads:[~2019-04-17  3:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-05 12:22 [PATCH] stm class: Fix out of bound access from bitmap allocation Sai Prakash Ranjan
2019-04-05 13:14 ` David Laight
2019-04-07  4:31   ` Sai Prakash Ranjan
2019-04-08 10:23     ` Robin Murphy
2019-04-08 10:33       ` David Laight
2019-04-08 10:52         ` Robin Murphy
2019-04-08 11:13           ` David Laight
2019-04-16 15:00 ` Alexander Shishkin
2019-04-17  3:33   ` Sai Prakash Ranjan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).