alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [patch] ALSA: compress_core: integer overflow in snd_compr_allocate_buffer()
@ 2012-09-05 12:32 Dan Carpenter
  2012-09-05 13:40 ` Takashi Iwai
  0 siblings, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2012-09-05 12:32 UTC (permalink / raw)
  To: Vinod Koul
  Cc: alsa-devel, Takashi Iwai, kernel-janitors, Pierre-Louis Bossart,
	Jesper Juhl, Namarta Kohli

These are 32 bit values that come from the user, we need to check for
integer overflows or we could end up allocating a smaller buffer than
expected.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index ec2118d..5a733e7 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -409,6 +409,10 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
 	unsigned int buffer_size;
 	void *buffer;
 
+	if (params->buffer.fragment_size == 0 ||
+	    params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size)
+		return -EINVAL;
+
 	buffer_size = params->buffer.fragment_size * params->buffer.fragments;
 	if (stream->ops->copy) {
 		buffer = NULL;

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-09-14 10:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 12:32 [patch] ALSA: compress_core: integer overflow in snd_compr_allocate_buffer() Dan Carpenter
2012-09-05 13:40 ` Takashi Iwai
2012-09-06 14:59   ` Dan Carpenter
2012-09-06 15:19     ` Takashi Iwai
2012-09-14  9:06       ` Takashi Iwai
2012-09-14  9:24         ` Vinod Koul
2012-09-14  9:28           ` Vinod Koul
2012-09-14  9:45             ` Takashi Iwai
2012-09-14  9:49               ` Vinod Koul
2012-09-14 10:00                 ` Takashi Iwai
2012-09-14  9:35           ` Dan Carpenter

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).