Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1394014 > unrolled thread

[patch] ALSA: isa/wavefront: prevent some out of bound writes

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-05-04 08:30 +0200
Last post2016-05-08 11:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] ALSA: isa/wavefront: prevent some out of bound writes Dan Carpenter <dan.carpenter@oracle.com> - 2016-05-04 08:30 +0200
    Re: [patch] ALSA: isa/wavefront: prevent some out of bound writes Takashi Iwai <tiwai@suse.de> - 2016-05-08 11:50 +0200

#1394014 — [patch] ALSA: isa/wavefront: prevent some out of bound writes

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-05-04 08:30 +0200
Subject[patch] ALSA: isa/wavefront: prevent some out of bound writes
Message-ID<ruYtQ-71w-7@gated-at.bofh.it>
"header->number" can be up to USHRT_MAX and it comes from the ioctl so
it needs to be capped.

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

diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index 69f76ff..718d5e3 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -785,6 +785,9 @@ wavefront_send_patch (snd_wavefront_t *dev, wavefront_patch_info *header)
 	DPRINT (WF_DEBUG_LOAD_PATCH, "downloading patch %d\n",
 				      header->number);
 
+	if (header->number >= ARRAY_SIZE(dev->patch_status))
+		return -EINVAL;
+
 	dev->patch_status[header->number] |= WF_SLOT_FILLED;
 
 	bptr = buf;
@@ -809,6 +812,9 @@ wavefront_send_program (snd_wavefront_t *dev, wavefront_patch_info *header)
 	DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n",
 		header->number);
 
+	if (header->number >= ARRAY_SIZE(dev->prog_status))
+		return -EINVAL;
+
 	dev->prog_status[header->number] = WF_SLOT_USED;
 
 	/* XXX need to zero existing SLOT_USED bit for program_status[i]
@@ -898,6 +904,9 @@ wavefront_send_sample (snd_wavefront_t *dev,
 		header->number = x;
 	}
 
+	if (header->number >= WF_MAX_SAMPLE)
+		return -EINVAL;
+
 	if (header->size) {
 
 		/* XXX it's a debatable point whether or not RDONLY semantics

[toc] | [next] | [standalone]


#1396406

FromTakashi Iwai <tiwai@suse.de>
Date2016-05-08 11:50 +0200
Message-ID<rwtvz-4bQ-3@gated-at.bofh.it>
In reply to#1394014
On Wed, 04 May 2016 08:27:37 +0200,
Dan Carpenter wrote:
> 
> "header->number" can be up to USHRT_MAX and it comes from the ioctl so
> it needs to be capped.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.


Takashi

> 
> diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
> index 69f76ff..718d5e3 100644
> --- a/sound/isa/wavefront/wavefront_synth.c
> +++ b/sound/isa/wavefront/wavefront_synth.c
> @@ -785,6 +785,9 @@ wavefront_send_patch (snd_wavefront_t *dev, wavefront_patch_info *header)
>  	DPRINT (WF_DEBUG_LOAD_PATCH, "downloading patch %d\n",
>  				      header->number);
>  
> +	if (header->number >= ARRAY_SIZE(dev->patch_status))
> +		return -EINVAL;
> +
>  	dev->patch_status[header->number] |= WF_SLOT_FILLED;
>  
>  	bptr = buf;
> @@ -809,6 +812,9 @@ wavefront_send_program (snd_wavefront_t *dev, wavefront_patch_info *header)
>  	DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n",
>  		header->number);
>  
> +	if (header->number >= ARRAY_SIZE(dev->prog_status))
> +		return -EINVAL;
> +
>  	dev->prog_status[header->number] = WF_SLOT_USED;
>  
>  	/* XXX need to zero existing SLOT_USED bit for program_status[i]
> @@ -898,6 +904,9 @@ wavefront_send_sample (snd_wavefront_t *dev,
>  		header->number = x;
>  	}
>  
> +	if (header->number >= WF_MAX_SAMPLE)
> +		return -EINVAL;
> +
>  	if (header->size) {
>  
>  		/* XXX it's a debatable point whether or not RDONLY semantics
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web