Commit 65f2b317 authored by Dan Carpenter's avatar Dan Carpenter Committed by Juerg Haefliger

ALSA: isa/wavefront: prevent some out of bound writes

BugLink: https://bugs.launchpad.net/bugs/1811252

[ Upstream commit 84d7a447 ]

"header->number" can be up to USHRT_MAX and it comes from the ioctl so
it needs to be capped.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 1db6aabf
...@@ -785,6 +785,9 @@ wavefront_send_patch (snd_wavefront_t *dev, wavefront_patch_info *header) ...@@ -785,6 +785,9 @@ wavefront_send_patch (snd_wavefront_t *dev, wavefront_patch_info *header)
DPRINT (WF_DEBUG_LOAD_PATCH, "downloading patch %d\n", DPRINT (WF_DEBUG_LOAD_PATCH, "downloading patch %d\n",
header->number); header->number);
if (header->number >= ARRAY_SIZE(dev->patch_status))
return -EINVAL;
dev->patch_status[header->number] |= WF_SLOT_FILLED; dev->patch_status[header->number] |= WF_SLOT_FILLED;
bptr = buf; bptr = buf;
...@@ -809,6 +812,9 @@ wavefront_send_program (snd_wavefront_t *dev, wavefront_patch_info *header) ...@@ -809,6 +812,9 @@ wavefront_send_program (snd_wavefront_t *dev, wavefront_patch_info *header)
DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n", DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n",
header->number); header->number);
if (header->number >= ARRAY_SIZE(dev->prog_status))
return -EINVAL;
dev->prog_status[header->number] = WF_SLOT_USED; dev->prog_status[header->number] = WF_SLOT_USED;
/* XXX need to zero existing SLOT_USED bit for program_status[i] /* XXX need to zero existing SLOT_USED bit for program_status[i]
...@@ -898,6 +904,9 @@ wavefront_send_sample (snd_wavefront_t *dev, ...@@ -898,6 +904,9 @@ wavefront_send_sample (snd_wavefront_t *dev,
header->number = x; header->number = x;
} }
if (header->number >= WF_MAX_SAMPLE)
return -EINVAL;
if (header->size) { if (header->size) {
/* XXX it's a debatable point whether or not RDONLY semantics /* XXX it's a debatable point whether or not RDONLY semantics
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment