clear-pkgs-linux-iot-lts2018/0239-ASoC-Intel-Skylake-Pro...

39 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jayachandran B <jayachandran.b@intel.com>
Date: Tue, 14 Jun 2016 10:39:48 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Probe-Limit the bytes to copy
If userspace happens to issue a copy with count > ring buffer size,
limit the count to the allocated ring buffer size to avoid out of
bound access into the buffer.
Change-Id: I7acbfb64bda299237a9d56bbac4a022d36b28bfd
Signed-off-by: Jayachandran B <jayachandran.b@intel.com>
Reviewed-on:
Reviewed-by: Babu, Ramesh <ramesh.babu@intel.com>
Tested-by: Babu, Ramesh <ramesh.babu@intel.com>
---
sound/soc/intel/skylake/skl-probe.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sound/soc/intel/skylake/skl-probe.c b/sound/soc/intel/skylake/skl-probe.c
index 7d2379806daf..507513eabbd6 100644
--- a/sound/soc/intel/skylake/skl-probe.c
+++ b/sound/soc/intel/skylake/skl-probe.c
@@ -230,6 +230,12 @@ int skl_probe_compr_copy(struct snd_compr_stream *stream, char __user *buf,
{
int offset = 0, availcount = 0, retval = 0, copy;
void *dstn;
+ /*
+ * If userspace happens to issue a copy with count > ring buffer size,
+ * limit the count to the allocated ring buffer size.
+ */
+ if (count > stream->runtime->buffer_size)
+ count = stream->runtime->buffer_size;
if (stream->direction == SND_COMPRESS_CAPTURE) {
offset = stream->runtime->total_bytes_transferred %
--
https://clearlinux.org