From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750894AbcEHJj7 (ORCPT ); Sun, 8 May 2016 05:39:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:33885 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbcEHJj6 (ORCPT ); Sun, 8 May 2016 05:39:58 -0400 Date: Sun, 08 May 2016 11:39:56 +0200 Message-ID: From: Takashi Iwai To: "Dan Carpenter" Cc: "Jaroslav Kysela" , , , Subject: Re: [patch] ALSA: isa/wavefront: prevent some out of bound writes In-Reply-To: <20160504062737.GI22064@mwanda> References: <20160504062737.GI22064@mwanda> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >