public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: [alsa-devel] [patch] [ALSA] seq_oss_event: missing range checks
Date: Mon, 04 Mar 2013 15:41:37 +0000	[thread overview]
Message-ID: <s5hlia3gojy.wl%tiwai@suse.de> (raw)
In-Reply-To: <20130304121918.GA587@longonot.mountain>

At Mon, 4 Mar 2013 15:19:18 +0300,
Dan Carpenter wrote:
> 
> The "dev" variable could be out of bounds.  Calling
> snd_seq_oss_synth_is_valid() checks that it is is a valid device
> which has been opened.  We check this inside set_note_event() so
> this function can't succeed without a valid "dev".  But we need to
> do the check earlier to prevent invalid dereferences and memory
> corruption.
> 
> One call tree where "dev" could be out of bounds is:
> -> snd_seq_oss_oob_user()
>    -> snd_seq_oss_process_event()
>       -> extended_event()
>          -> note_on_event()
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied.


Takashi

> 
> diff --git a/sound/core/seq/oss/seq_oss_event.c b/sound/core/seq/oss/seq_oss_event.c
> index 066f5f3..c390886 100644
> --- a/sound/core/seq/oss/seq_oss_event.c
> +++ b/sound/core/seq/oss/seq_oss_event.c
> @@ -285,7 +285,12 @@ local_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev
>  static int
>  note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev)
>  {
> -	struct seq_oss_synthinfo *info = &dp->synths[dev];
> +	struct seq_oss_synthinfo *info;
> +
> +	if (!snd_seq_oss_synth_is_valid(dp, dev))
> +		return -ENXIO;
> +
> +	info = &dp->synths[dev];
>  	switch (info->arg.event_passing) {
>  	case SNDRV_SEQ_OSS_PROCESS_EVENTS:
>  		if (! info->ch || ch < 0 || ch >= info->nr_voices) {
> @@ -340,7 +345,12 @@ note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, st
>  static int
>  note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev)
>  {
> -	struct seq_oss_synthinfo *info = &dp->synths[dev];
> +	struct seq_oss_synthinfo *info;
> +
> +	if (!snd_seq_oss_synth_is_valid(dp, dev))
> +		return -ENXIO;
> +
> +	info = &dp->synths[dev];
>  	switch (info->arg.event_passing) {
>  	case SNDRV_SEQ_OSS_PROCESS_EVENTS:
>  		if (! info->ch || ch < 0 || ch >= info->nr_voices) {
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

      reply	other threads:[~2013-03-04 15:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-04 12:19 [patch] [ALSA] seq_oss_event: missing range checks Dan Carpenter
2013-03-04 15:41 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hlia3gojy.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox