ALSA: pcm: fix divide error in snd_pcm_lib_ioctl
authorZubin Mithra <zsm@chromium.org>
Fri, 27 Aug 2021 15:37:35 +0000 (08:37 -0700)
committerTakashi Iwai <tiwai@suse.de>
Fri, 27 Aug 2021 20:34:12 +0000 (22:34 +0200)
Syzkaller reported a divide error in snd_pcm_lib_ioctl. fifo_size
is of type snd_pcm_uframes_t(unsigned long). If frame_size
is 0x100000000, the error occurs.

Fixes: a9960e6a293e ("ALSA: pcm: fix fifo_size frame calculation")
Signed-off-by: Zubin Mithra <zsm@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210827153735.789452-1-zsm@chromium.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_lib.c

index 7d5883432085a83854d4c218d384cfe18038865b..a144a3f68e9eb41164fba0f98e8b7416c7cc8a5a 100644 (file)
@@ -1746,7 +1746,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
                channels = params_channels(params);
                frame_size = snd_pcm_format_size(format, channels);
                if (frame_size > 0)
-                       params->fifo_size /= (unsigned)frame_size;
+                       params->fifo_size /= frame_size;
        }
        return 0;
 }