ALSA: pcm: check for integer overflow during multiplication
Channel info data structure is parsed from userspace and if user does not set the no. of channels correctly, it could lead to security vulnerability if we don't check for overflow when the no. of channels is multiplied with pcm bit width. Add a condition to check for overflow during multiplication. CRs-fixed: 537818 Change-Id: Ib9631b6e45d77b39be2c27343d4aee3e9244d8cc Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
This commit is contained in:
parent
f928605b0e
commit
6ba6d2e983
1 changed files with 11 additions and 0 deletions
|
@ -1792,6 +1792,11 @@ static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream,
|
|||
switch (runtime->access) {
|
||||
case SNDRV_PCM_ACCESS_MMAP_INTERLEAVED:
|
||||
case SNDRV_PCM_ACCESS_RW_INTERLEAVED:
|
||||
if ((UINT_MAX/width) < info->channel) {
|
||||
snd_printd("%s: integer overflow while multiply\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
info->first = info->channel * width;
|
||||
info->step = runtime->channels * width;
|
||||
break;
|
||||
|
@ -1799,6 +1804,12 @@ static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream,
|
|||
case SNDRV_PCM_ACCESS_RW_NONINTERLEAVED:
|
||||
{
|
||||
size_t size = runtime->dma_bytes / runtime->channels;
|
||||
|
||||
if ((size > 0) && ((UINT_MAX/(size * 8)) < info->channel)) {
|
||||
snd_printd("%s: integer overflow while multiply\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
info->first = info->channel * size * 8;
|
||||
info->step = width;
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue